#[non_exhaustive]pub struct JwtConfig {
pub secret: String,
pub default_expiry: Option<u64>,
pub leeway: u64,
pub issuer: Option<String>,
pub audience: Option<String>,
}Expand description
YAML configuration for JWT services.
§Example
jwt:
secret: "${JWT_SECRET}"
default_expiry: 3600
leeway: 5
issuer: "my-app"
audience: "api"Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.secret: StringHMAC secret used for signing and verifying tokens.
default_expiry: Option<u64>Default token lifetime in seconds. Applied automatically by JwtEncoder::encode()
when claims.exp is None. If None, tokens without an exp are rejected by the decoder.
leeway: u64Clock skew tolerance in seconds. Applied to both exp and nbf checks.
Defaults to 0 when omitted from YAML.
issuer: Option<String>Required issuer (iss). When set, JwtDecoder::decode() rejects tokens
whose iss does not match.
audience: Option<String>Required audience (aud). When set, JwtDecoder::decode() rejects tokens
whose aud does not match.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JwtConfig
impl<'de> Deserialize<'de> for JwtConfig
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 JwtConfig
impl RefUnwindSafe for JwtConfig
impl Send for JwtConfig
impl Sync for JwtConfig
impl Unpin for JwtConfig
impl UnsafeUnpin for JwtConfig
impl UnwindSafe for JwtConfig
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