pub struct JwtConfig {
pub secret: Option<Zeroizing<String>>,
pub public_key_pem: Option<Zeroizing<String>>,
pub issuer: Option<String>,
pub audience: Option<String>,
pub require_audience: bool,
pub jwks_url: Option<String>,
pub subject_claim: Option<String>,
pub algorithm: Option<String>,
pub role_claim: Option<String>,
}Expand description
JWT validation configuration.
Security: The secret and public_key_pem fields are redacted
in Debug output to prevent credential leakage in logs.
Fields§
§secret: Option<Zeroizing<String>>HMAC secret for HS256/HS384/HS512 (base64-encoded or raw).
public_key_pem: Option<Zeroizing<String>>Public key PEM for the asymmetric families.
RSA (RS*, PS*) and elliptic-curve (ES*) keys both live here:
the family comes from algorithm, and mixing the two used to mean
an EC key was parsed as RSA, failed, and left the validator with no
key at all — which every token then failed against.
issuer: Option<String>Expected issuer (iss claim).
audience: Option<String>Expected audience (aud claim).
require_audience: boolWhether to require audience validation. When true (default)
and audience is None, validator construction fails.
Set to false only if tokens legitimately carry no audience.
jwks_url: Option<String>JWKS URL for fetching public keys (OIDC discovery).
subject_claim: Option<String>Claim name for the principal identity (default: sub).
algorithm: Option<String>Algorithm to use. Default: HS256.
role_claim: Option<String>Claim name or dot-separated path for role extraction (default: roles).
Examples: "roles", "realm_access.roles", "https://example.com/roles".
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>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more