pub struct JsonWebTokenOptions { /* private fields */ }Expand description
Options used to configure a JsonWebToken codec.
Use this when you need explicit control over signing keys, verification keys, key identifiers, or validation settings.
Implementations§
Source§impl JsonWebTokenOptions
impl JsonWebTokenOptions
Sourcepub fn from_es384_pem(
private_key_pem: &[u8],
public_key_pem: &[u8],
) -> Result<Self>
pub fn from_es384_pem( private_key_pem: &[u8], public_key_pem: &[u8], ) -> Result<Self>
Creates ES384 JWT options from PEM-encoded private and public keys.
§Errors
Returns a JWT processing error when either key cannot be parsed.
Sourcepub fn for_es384_verification_only(public_key_pem: &[u8]) -> Result<Self>
pub fn for_es384_verification_only(public_key_pem: &[u8]) -> Result<Self>
Creates verification-only ES384 JWT options from a PEM public key.
Codecs built from these options can decode and validate tokens but will reject encoding attempts.
§Errors
Returns a JWT processing error when the public key cannot be parsed.
Sourcepub fn for_es384_jwks_keys(keys: &[EcP384Jwk]) -> Result<Self>
pub fn for_es384_jwks_keys(keys: &[EcP384Jwk]) -> Result<Self>
Creates verification-only ES384 options from JWKS keys.
This enables key selection by kid and rejects JWTs that do not include
a matching kid.
§Errors
Returns a JWT processing error if no valid ES384 verification key can be constructed from the provided JWKS entries.
Sourcepub fn verification_key_count(&self) -> usize
pub fn verification_key_count(&self) -> usize
Returns the number of configured verification keys.
Sourcepub fn allows_missing_kid_fallback(&self) -> bool
pub fn allows_missing_kid_fallback(&self) -> bool
Returns whether verification accepts missing kid by using a fallback
decoding key.
Sourcepub fn with_key_id(self, key_id: impl Into<String>) -> Self
pub fn with_key_id(self, key_id: impl Into<String>) -> Self
Returns updated options with an explicit kid for signing.
This always keeps a canonical ES384 JWT header (alg = ES384,
typ = JWT, kid = ...).
Sourcepub fn with_verification_keys(
self,
keys: HashMap<String, DecodingKey>,
allow_missing_kid_fallback: bool,
) -> Self
pub fn with_verification_keys( self, keys: HashMap<String, DecodingKey>, allow_missing_kid_fallback: bool, ) -> Self
Returns updated options with a replaced verification-key map.
The first key is used as fallback only when
allow_missing_kid_fallback is true.
Sourcepub fn with_added_verification_key(
self,
kid: impl Into<String>,
key: DecodingKey,
) -> Self
pub fn with_added_verification_key( self, kid: impl Into<String>, key: DecodingKey, ) -> Self
Returns updated options with an added verification key.
Sourcepub fn with_validation(self, validation: Validation) -> Self
pub fn with_validation(self, validation: Validation) -> Self
Returns updated options with custom validation settings.
Trait Implementations§
Source§impl Clone for JsonWebTokenOptions
impl Clone for JsonWebTokenOptions
Source§fn clone(&self) -> JsonWebTokenOptions
fn clone(&self) -> JsonWebTokenOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JsonWebTokenOptions
impl Debug for JsonWebTokenOptions
Source§impl Default for JsonWebTokenOptions
impl Default for JsonWebTokenOptions
Source§fn default() -> Self
fn default() -> Self
Creates ES384 encoding and decoding keys from built-in development keys.
This default is intended for tests and local development only. Production
deployments should provide explicit key material with
JsonWebTokenOptions::from_es384_pem.