pub struct TokenClaims {
pub sub: Option<String>,
pub iss: Option<String>,
pub aud: Option<String>,
pub exp: Option<u64>,
pub iat: Option<u64>,
pub nbf: Option<u64>,
pub jti: Option<String>,
pub tenant_id: Option<String>,
pub roles: Vec<String>,
pub permissions: Vec<String>,
pub extra: HashMap<String, Value>,
}Expand description
JWT token claims
Fields§
§sub: Option<String>Subject (user ID)
iss: Option<String>Issuer
aud: Option<String>Audience
exp: Option<u64>Expiration time (Unix timestamp)
iat: Option<u64>Issued at (Unix timestamp)
nbf: Option<u64>Not before (Unix timestamp)
jti: Option<String>JWT ID
tenant_id: Option<String>Tenant ID (custom claim)
roles: Vec<String>Roles (custom claim)
permissions: Vec<String>Permissions (custom claim)
extra: HashMap<String, Value>Additional custom claims
Implementations§
Source§impl TokenClaims
impl TokenClaims
Sourcepub fn expires_in(self, duration: Duration) -> Self
pub fn expires_in(self, duration: Duration) -> Self
Set expiration
Sourcepub fn for_tenant(self, tenant_id: impl Into<String>) -> Self
pub fn for_tenant(self, tenant_id: impl Into<String>) -> Self
Set tenant
Sourcepub fn with_permission(self, permission: impl Into<String>) -> Self
pub fn with_permission(self, permission: impl Into<String>) -> Self
Add permission
Sourcepub fn with_claim(self, key: impl Into<String>, value: impl Serialize) -> Self
pub fn with_claim(self, key: impl Into<String>, value: impl Serialize) -> Self
Add custom claim
Trait Implementations§
Source§impl Clone for TokenClaims
impl Clone for TokenClaims
Source§fn clone(&self) -> TokenClaims
fn clone(&self) -> TokenClaims
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenClaims
impl Debug for TokenClaims
Source§impl Default for TokenClaims
impl Default for TokenClaims
Source§impl<'de> Deserialize<'de> for TokenClaims
impl<'de> Deserialize<'de> for TokenClaims
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TokenClaims
impl RefUnwindSafe for TokenClaims
impl Send for TokenClaims
impl Sync for TokenClaims
impl Unpin for TokenClaims
impl UnwindSafe for TokenClaims
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.