pub struct AuthenticatedPrincipal {
pub subject: String,
pub tenant: Option<String>,
pub scopes: Vec<String>,
pub issuer: Option<String>,
pub expires_at: Option<DateTime<Utc>>,
pub method: AuthenticationMethod,
pub assurance: IdentityAssurance,
}Expand description
Transport-neutral result of successful authentication.
This type lives in rvoip-core-traits so auth implementations and protocol
adapters can carry the same complete identity without creating a dependency
cycle. Resource authorization should compare Self::ownership_key, not
subject by itself.
Fields§
§subject: String§tenant: Option<String>§scopes: Vec<String>§issuer: Option<String>§expires_at: Option<DateTime<Utc>>§method: AuthenticationMethod§assurance: IdentityAssuranceImplementations§
Source§impl AuthenticatedPrincipal
impl AuthenticatedPrincipal
pub fn anonymous() -> AuthenticatedPrincipal
pub fn has_scope(&self, scope: &str) -> bool
pub fn require_scope(&self, scope: &str) -> Result<(), BearerAuthError>
pub fn ownership_key(&self) -> PrincipalOwnershipKey
pub fn has_same_owner(&self, other: &AuthenticatedPrincipal) -> bool
Sourcepub fn is_expired_at(&self, now: DateTime<Utc>) -> bool
pub fn is_expired_at(&self, now: DateTime<Utc>) -> bool
Whether this principal is expired at now.
An expiry equal to now is already expired. Principals without an
expiry remain active until their backing authentication policy says
otherwise.
pub fn is_expired(&self) -> bool
Sourcepub fn from_assurance(assurance: IdentityAssurance) -> AuthenticatedPrincipal
pub fn from_assurance(assurance: IdentityAssurance) -> AuthenticatedPrincipal
Compatibility mapping for authentication providers that currently
produce only an IdentityAssurance. Validators with issuer, tenant,
or credential-expiry information should construct a full principal.
pub fn from_assurance_with_method( assurance: IdentityAssurance, method: AuthenticationMethod, ) -> AuthenticatedPrincipal
Trait Implementations§
Source§impl Clone for AuthenticatedPrincipal
impl Clone for AuthenticatedPrincipal
Source§fn clone(&self) -> AuthenticatedPrincipal
fn clone(&self) -> AuthenticatedPrincipal
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuthenticatedPrincipal
impl RefUnwindSafe for AuthenticatedPrincipal
impl Send for AuthenticatedPrincipal
impl Sync for AuthenticatedPrincipal
impl Unpin for AuthenticatedPrincipal
impl UnsafeUnpin for AuthenticatedPrincipal
impl UnwindSafe for AuthenticatedPrincipal
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more