pub struct JwtPlugin { /* private fields */ }Expand description
Issue session JWTs with keys persisted through JwksStore.
Implementations§
Source§impl JwtPlugin
impl JwtPlugin
Sourcepub fn callbacks<S: AuthSchema>(
self,
callbacks: JwtCallbacks<S>,
) -> impl AuthPlugin<S>
pub fn callbacks<S: AuthSchema>( self, callbacks: JwtCallbacks<S>, ) -> impl AuthPlugin<S>
Attach schema-aware key adapter callbacks after configuring plugin options.
Source§impl JwtPlugin
impl JwtPlugin
Sourcepub async fn sign<S: AuthSchema>(
&self,
payload: Map<String, Value>,
ctx: &AuthContext<S>,
) -> AuthResult<String>
pub async fn sign<S: AuthSchema>( &self, payload: Map<String, Value>, ctx: &AuthContext<S>, ) -> AuthResult<String>
Sign an application payload with the same persisted keys as /token.
Sourcepub async fn sign_with_options<S: AuthSchema>(
&self,
payload: Map<String, Value>,
options: &JwtSigningOptions,
ctx: &AuthContext<S>,
) -> AuthResult<String>
pub async fn sign_with_options<S: AuthSchema>( &self, payload: Map<String, Value>, options: &JwtSigningOptions, ctx: &AuthContext<S>, ) -> AuthResult<String>
Sign a native payload with explicit protected headers and key selection.
Use sign_in_endpoint to retain an endpoint request and transaction.
Sourcepub async fn sign_in_endpoint<S: AuthSchema>(
&self,
payload: Map<String, Value>,
options: &JwtSigningOptions,
endpoint: &EndpointContext<'_, S>,
) -> AuthResult<String>
pub async fn sign_in_endpoint<S: AuthSchema>( &self, payload: Map<String, Value>, options: &JwtSigningOptions, endpoint: &EndpointContext<'_, S>, ) -> AuthResult<String>
Sign with the supplied endpoint context, including its active transaction.
Source§impl JwtPlugin
impl JwtPlugin
Sourcepub async fn verify<S: AuthSchema>(
&self,
token: &str,
issuer: Option<&str>,
ctx: &AuthContext<S>,
) -> AuthResult<Option<Map<String, Value>>>
pub async fn verify<S: AuthSchema>( &self, token: &str, issuer: Option<&str>, ctx: &AuthContext<S>, ) -> AuthResult<Option<Map<String, Value>>>
Verify a token with adapter keys. Invalid tokens and verification adapter errors return None.
The optional issuer overrides the configured issuer. Like upstream verifyJWT,
this reads local adapter keys even when remote_url is configured.
Sourcepub async fn verify_in_endpoint<S: AuthSchema>(
&self,
token: &str,
issuer: Option<&str>,
endpoint: &EndpointContext<'_, S>,
) -> AuthResult<Option<Map<String, Value>>>
pub async fn verify_in_endpoint<S: AuthSchema>( &self, token: &str, issuer: Option<&str>, endpoint: &EndpointContext<'_, S>, ) -> AuthResult<Option<Map<String, Value>>>
Verify with the supplied endpoint context and its key-adapter callbacks.
Source§impl JwtPlugin
impl JwtPlugin
pub fn new() -> Self
pub fn with_config(config: JwtPluginConfig) -> Self
pub fn modulus_length(self, val: u32) -> Self
pub fn key_pair_configs(self, val: Vec<JwtKeyPairConfig>) -> Self
pub fn remote_url(self, val: String) -> Self
pub fn custom_sign(self, val: JwtCustomSign) -> Self
pub fn define_payload(self, val: JwtDefinePayload) -> Self
pub fn get_subject(self, val: JwtGetSubject) -> Self
pub fn jwks_path(self, val: impl Into<String>) -> Self
pub fn algorithm(self, val: JwtAlgorithm) -> Self
pub fn issuer(self, val: String) -> Self
pub fn audience(self, val: JwtAudience) -> Self
pub fn rotation_interval(self, val: Duration) -> Self
pub fn grace_period(self, val: Duration) -> Self
pub fn disable_private_key_encryption(self, val: bool) -> Self
pub fn disable_setting_jwt_header(self, val: bool) -> Self
Source§impl JwtPlugin
impl JwtPlugin
Sourcepub fn expiration_time(self, expiration: impl Into<JwtExpiration>) -> Self
pub fn expiration_time(self, expiration: impl Into<JwtExpiration>) -> Self
Set a relative duration, an absolute date, or a NumericDate in seconds.
Source§impl JwtPlugin
impl JwtPlugin
Sourcepub async fn create_key_pair<S: AuthSchema>(
&self,
parameters: JwtKeyPairConfig,
ctx: &AuthContext<S>,
) -> AuthResult<Jwk>
pub async fn create_key_pair<S: AuthSchema>( &self, parameters: JwtKeyPairConfig, ctx: &AuthContext<S>, ) -> AuthResult<Jwk>
Provision a local key with explicit parameters.
Sourcepub async fn create_key_pair_in_endpoint<S: AuthSchema>(
&self,
parameters: JwtKeyPairConfig,
endpoint: &EndpointContext<'_, S>,
) -> AuthResult<Jwk>
pub async fn create_key_pair_in_endpoint<S: AuthSchema>( &self, parameters: JwtKeyPairConfig, endpoint: &EndpointContext<'_, S>, ) -> AuthResult<Jwk>
Provision a key with the supplied endpoint context and active transaction.