Skip to main content

Claims

Struct Claims 

Source
pub struct Claims {
Show 13 fields pub sub: String, pub aud: String, pub iss: String, pub sid: String, pub exp: i64, pub iat: i64, pub email: Option<String>, pub email_verified: Option<bool>, pub amr: Vec<String>, pub sso_connection: Option<String>, pub auth_time: Option<i64>, pub roles: Vec<String>, pub acr: Option<String>,
}
Expand description

The claims a verified access token carries.

Fields§

§sub: String

The user this token speaks for.

§aud: String

The client the token was minted for; checked against ours.

§iss: String

The issuing service.

§sid: String

The session behind the token. A consuming app that needs instant revocation asks the auth service about this id; see the crate docs for why that is the exception rather than the rule.

§exp: i64§iat: i64§email: Option<String>§email_verified: Option<bool>§amr: Vec<String>

Authentication methods used at login (RFC 8176).

§sso_connection: Option<String>

The enterprise SSO connection this session was signed in through (issue #627), present only while that connection belongs to the client the token was minted for — which is this one, or the audience check above would already have refused the token.

None for every other way in, and for a token minted before the claim existed.

§auth_time: Option<i64>

When the person last authenticated in a real ceremony, epoch seconds (issue #912). None only for a token minted before the claim existed, which Claims::authenticated_within treats as not fresh.

§roles: Vec<String>

The account’s roles in the issuing instance (issue #912), present only for a client the instance registered to receive them. Empty otherwise.

§acr: Option<String>

The authentication context (acr), urn:cratefield:stepup when the session spent a step-up transaction (issue #912). Absent otherwise.

Implementations§

Source§

impl Claims

Source

pub fn stepped_up_within(&self, max_age_secs: i64, now: i64) -> bool

Whether the person proved who they are with a passkey or an email link within the last max_age_secs seconds, measured from now (issue #912). This is the check a payment, signature or other irreversible approval gates on: a password, a federated sign-in or an old login does not pass it, however recent. false when the token has no auth_time.

Source

pub fn authenticated_within(&self, max_age_secs: i64, now: i64) -> bool

Whether the person authenticated within the last max_age_secs seconds, measured from now (epoch seconds, taken from the caller’s clock). false when the token has no auth_time.

A relying party that is about to approve something checks this itself. Verification establishes who signed the token, not how recently the person proved who they are.

Source

pub fn signed_in_via_sso(&self, connection_id: &str) -> bool

Whether this token came through one specific enterprise SSO connection, as opposed to any other way in.

Both halves are required. A token that named the connection without sso in amr would be one from before the claim existed, or one minted by something that did not go through the SSO flow, and a caller that gates on enterprise membership should refuse both.

Trait Implementations§

Source§

impl Clone for Claims

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Claims

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Claims

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Claims

Source§

impl PartialEq for Claims

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Claims

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more