pub trait ITokenIssuer: Send + Sync {
// Required method
fn issue<'life0, 'async_trait>(
&'life0 self,
claims: TokenClaims,
) -> Pin<Box<dyn Future<Output = Result<IssuedToken, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Mint a token from TokenClaims.
Implementations embed a unique IssuedToken::jti and an absolute expiry in
Unix seconds (expires_at_unix_secs), so callers can revoke the token later
without decoding it again.
ⓘ
let issued = token_issuer.issue(
TokenClaims::new(&user.id)
.with_roles(user.roles.clone())
.with_claim("tenant_id", &user.tenant_id),
).await?;
store.revoke(&issued.jti).await?; // logoutRequired Methods§
Sourcefn issue<'life0, 'async_trait>(
&'life0 self,
claims: TokenClaims,
) -> Pin<Box<dyn Future<Output = Result<IssuedToken, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn issue<'life0, 'async_trait>(
&'life0 self,
claims: TokenClaims,
) -> Pin<Box<dyn Future<Output = Result<IssuedToken, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Sign claims into a token.
Returns a typed Error for caller mistakes (for
example an empty subject) and for signing failures; it must not panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".