Skip to main content

Claims

Struct Claims 

Source
pub struct Claims {
    pub sub: String,
    pub email: String,
    pub name: String,
    pub iss: String,
    pub aud: String,
    pub exp: i64,
    pub iat: i64,
    pub nbf: Option<i64>,
    pub sid: String,
    pub scope: Vec<String>,
    pub roles: Vec<String>,
    pub attrs: BTreeMap<String, Vec<String>>,
}
Expand description

Verified token claims. Mirrors the auth-service Claims exactly so a token signed there round-trips here. sub carries the user pid.

The field set is a contract with the auth-service: the service defines an identical struct, and changing one without the other breaks token round-tripping. exp / iat / nbf are unix seconds.

Fields§

§sub: String

Subject — the user pid (UUID string); the stable identifier a peer service keys its authorization on.

§email: String

User email, surfaced for convenience at the edge; not used for authorization decisions.

§name: String

Human-readable display name carried alongside the subject.

§iss: String

Issuer (iss) — the auth-service that minted the token. Checked against the verifier’s configured issuer.

§aud: String

Audience (aud) — the intended recipient service. Checked against the verifier’s configured audience so a token issued for one peer cannot be replayed against another.

§exp: i64

Expiry (exp), unix seconds. Tokens at or past this instant are rejected. Issued ~5 minutes out (the session is the durable thing).

§iat: i64

Issued-at (iat), unix seconds — when the token was minted.

§nbf: Option<i64>

Not-before (nbf), unix seconds. When present, tokens before this instant are rejected. Omitted from the wire form when None.

§sid: String

Session id (sid) — the originating server-side session, so a token can be correlated back to (and revoked with) its session.

§scope: Vec<String>

Granted scopes, if any. Empty when the token carries none.

Deprecated for authorization (kept on the wire for compatibility; removal is a future major): the ABAC guard ignores scope and decides from attrs instead. See agents/share/authorization-attributes.md §3.

§roles: Vec<String>

Granted roles, if any. Empty when the token carries none.

Deprecated for authorization (kept on the wire for compatibility; removal is a future major): the ABAC guard ignores roles and decides from attrs instead — a role, where one is wanted, is just another attribute (role=editor). See agents/share/authorization-attributes.md §3.

§attrs: BTreeMap<String, Vec<String>>

Subject attributes for ABAC authorization — a string→strings map minted by the auth-service from the user’s assigned attributes (e.g. access: ["write"], dept: ["cardiology"], svc: ["true"] for machine peers). Multi-valued keys mean “has each of these values”; policies match set-membership; unknown attributes are inert (forward-compatible). Absent on the wire (old tokens) ⇒ empty map — no re-issue needed. Evaluated by the abac engine per agents/share/authorization-attributes.md §2–§3, alongside the pseudo-attributes sub and email.

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 Serialize for Claims

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.