pub struct TokenClaims {
pub sub: String,
pub exp: Option<i64>,
pub permissions: Vec<Permission>,
pub allowed_paths: Vec<String>,
}Expand description
Parsed, verified token payload used for fine-grained authorization.
All fields except sub are optional so that minimal tokens remain
usable (validation is performed by the Validator).
Fields§
§sub: StringSubject — the user or client the token belongs to.
exp: Option<i64>Unix timestamp (seconds) at which the token expires.
permissions: Vec<Permission>Permissions granted to this token. Empty means “no permissions”.
allowed_paths: Vec<String>Path prefixes the token may access. Empty means “no paths allowed”.
Implementations§
Source§impl TokenClaims
impl TokenClaims
Sourcepub fn is_expired(&self, now: i64) -> bool
pub fn is_expired(&self, now: i64) -> bool
Returns true if now (unix seconds) is past exp.
Sourcepub fn has_permission(&self, perm: Permission) -> bool
pub fn has_permission(&self, perm: Permission) -> bool
Returns true if this token grants perm.
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 (const: unstable) · 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<'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
impl Eq for TokenClaims
Source§impl PartialEq for TokenClaims
impl PartialEq for TokenClaims
Source§impl Serialize for TokenClaims
impl Serialize for TokenClaims
impl StructuralPartialEq for TokenClaims
Auto Trait Implementations§
impl Freeze for TokenClaims
impl RefUnwindSafe for TokenClaims
impl Send for TokenClaims
impl Sync for TokenClaims
impl Unpin for TokenClaims
impl UnsafeUnpin for TokenClaims
impl UnwindSafe for TokenClaims
Blanket Implementations§
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