pub struct JWTClaims<CustomClaims> {
    pub issued_at: Option<UnixTimeStamp>,
    pub expires_at: Option<UnixTimeStamp>,
    pub invalid_before: Option<UnixTimeStamp>,
    pub issuer: Option<String>,
    pub subject: Option<String>,
    pub audiences: Option<Audiences>,
    pub jwt_id: Option<String>,
    pub nonce: Option<String>,
    pub custom: CustomClaims,
}
Expand description

A set of JWT claims.

The CustomClaims parameter can be set to NoCustomClaims if only standard claims are used, or to a user-defined type that must be serde-serializable if custom claims are required.

Fields

issued_at: Option<UnixTimeStamp>

Time the claims were created at

expires_at: Option<UnixTimeStamp>

Time the claims expire at

invalid_before: Option<UnixTimeStamp>

Time the claims will be invalid until

issuer: Option<String>

Issuer - This can be set to anything application-specific

subject: Option<String>

Subject - This can be set to anything application-specific

audiences: Option<Audiences>

Audience

jwt_id: Option<String>

JWT identifier

That property was originally designed to avoid replay attacks, but keeping all previously sent JWT token IDs is unrealistic.

Replay attacks are better addressed by keeping only the timestamp of the last valid token for a user, and rejecting anything older in future tokens.

nonce: Option<String>

Nonce

custom: CustomClaims

Custom (application-defined) claims

Implementations

Set the token as not being valid until unix_timestamp

Set the issuer

Set the subject

Register one or more audiences (optional recipient identifiers), as a set

Set a unique audience (an optional recipient identifier), as a string

Set the JWT identifier

Set the nonce

Create a nonce, attach it and return it

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.