Skip to main content

Claims

Struct Claims 

Source
pub struct Claims<S: ScopeSet> {
    pub iss: String,
    pub sub: String,
    pub aud: Vec<String>,
    pub exp: i64,
    pub iat: i64,
    pub nonce: String,
    pub azp: Option<String>,
    pub auth_time: Option<i64>,
    pub acr: Option<String>,
    pub amr: Option<Vec<String>>,
    /* private fields */
}
Expand description

Verified id_token payload. S: ScopeSet is the type-level scope witness — the engine sets it to the scope struct matching the requested OAuth scope parameter, and the resulting value’s PII accessors are bounded by S’s implemented marker traits.

── M72 acceptance evidence (RFC §6.11.1 D2) ────────────────────────────

Calling .email() on a Claims<Openid> is a compile error, not a runtime check. The doc-test below is the standing acceptance fixture for the type-level enforcement invariant — cargo test --doc -p ppoppo-token runs it and asserts the snippet fails to compile.

use ppoppo_token::id_token::Claims;
use ppoppo_token::id_token::scopes::Openid;

fn _compile_fail(c: &Claims<Openid>) -> &str {
    c.email() // ERROR: method `email` not in scope (requires HasEmail)
}

Granting the email scope at issuance time satisfies the bound:

use ppoppo_token::id_token::Claims;
use ppoppo_token::id_token::scopes::Email;

fn _compiles(c: &Claims<Email>) -> &str { c.email() }

Fields§

§iss: String§sub: String§aud: Vec<String>§exp: i64§iat: i64§nonce: String

Conditionally required: present iff the RP sent nonce in the auth request. Engine-side: VerifyConfig::id_token requires an expected_nonce, so reaching the engine implies nonce is expected; M66 fires when this field is empty after parsing.

§azp: Option<String>

azp (authorized party) — OIDC §2. Set when the audience is multi-valued; the M69 gate (Phase 10.5) verifies it equals the RP’s client_id when aud.len() > 1.

§auth_time: Option<i64>

auth_time — when the End-User authentication occurred. Required when the max_age request parameter or auth_time essential claim was sent; surfaced unconditionally so the M70 gate (Phase 10.6) can read it.

§acr: Option<String>

acr — Authentication Context Class Reference. OIDC §2.

§amr: Option<Vec<String>>

amr — Authentication Methods References (e.g. ["pwd", "mfa"]).

Implementations§

Source§

impl<S: HasEmail> Claims<S>

email scope — OIDC §5.4.

Source

pub fn email(&self) -> &str

email is REQUIRED if the issuer emits the email scope at all (OIDC §5.4). Engine deserialization populates Some(_) when the wire contains the claim; the accessor unwraps via expect() because reaching this method bound (S: HasEmail) already proves the IdP honored the scope. A missing email on a HasEmail token is an issuer drift, surfaced as a panic so the regression is loud — if this path is reachable in production. Phase 10.8 (M72) will replace expect with a verify-time rejection so the panic becomes structurally unreachable.

Source

pub fn email_verified(&self) -> Option<bool>

Source§

impl<S: HasProfile> Claims<S>

profile scope — OIDC §5.4 (name / locale / updated_at family).

Source

pub fn name(&self) -> Option<&str>

Source

pub fn given_name(&self) -> Option<&str>

Source

pub fn family_name(&self) -> Option<&str>

Source

pub fn middle_name(&self) -> Option<&str>

Source

pub fn nickname(&self) -> Option<&str>

Source

pub fn preferred_username(&self) -> Option<&str>

Source

pub fn profile(&self) -> Option<&str>

Source

pub fn picture(&self) -> Option<&str>

Source

pub fn website(&self) -> Option<&str>

Source

pub fn gender(&self) -> Option<&str>

Source

pub fn birthdate(&self) -> Option<&str>

Source

pub fn zoneinfo(&self) -> Option<&str>

Source

pub fn locale(&self) -> Option<&str>

Source

pub fn updated_at(&self) -> Option<i64>

Source§

impl<S: HasPhone> Claims<S>

phone scope — OIDC §5.4.

Source§

impl<S: HasAddress> Claims<S>

address scope — OIDC §5.4 (single structured claim).

Source

pub fn address(&self) -> Option<&AddressClaim>

Trait Implementations§

Source§

impl<S: Clone + ScopeSet> Clone for Claims<S>

Source§

fn clone(&self) -> Claims<S>

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<S: Debug + ScopeSet> Debug for Claims<S>

Source§

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

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

impl<S: PartialEq + ScopeSet> PartialEq for Claims<S>

Source§

fn eq(&self, other: &Claims<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Eq + ScopeSet> Eq for Claims<S>

Source§

impl<S: ScopeSet> StructuralPartialEq for Claims<S>

Auto Trait Implementations§

§

impl<S> Freeze for Claims<S>

§

impl<S> RefUnwindSafe for Claims<S>
where S: RefUnwindSafe,

§

impl<S> Send for Claims<S>
where S: Send,

§

impl<S> Sync for Claims<S>
where S: Sync,

§

impl<S> Unpin for Claims<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Claims<S>

§

impl<S> UnwindSafe for Claims<S>
where S: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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