pub struct JwtConfig {
pub issuer: String,
pub audience: String,
pub algorithms: Vec<Algorithm>,
pub jwks_uri: Option<String>,
pub jwks_refresh: Duration,
pub clock_skew: Duration,
}Expand description
Configuration for JwtValidator.
Fields§
§issuer: StringExpected iss claim.
audience: StringExpected aud claim.
algorithms: Vec<Algorithm>Whitelist of accepted signing algorithms (RFC 8725 §3.1).
Default = [EdDSA] because verify_signature only implements
Ed25519 today; RS256/ES256 are reserved for v2.1. Operators
who need them today should keep the default and configure
their IdP to sign with EdDSA (see with_algorithms_try).
jwks_uri: Option<String>JWKS URI (optional). If set, keys are fetched from this URL.
jwks_refresh: DurationJWKS refresh interval. Default = 30 s. Read from the
AGENTGUARD_JWKS_REFRESH env var (humantime format).
clock_skew: DurationClock skew tolerance for exp/nbf.
Implementations§
Source§impl JwtConfig
impl JwtConfig
pub fn new(issuer: impl Into<String>, audience: impl Into<String>) -> Self
Sourcepub fn with_algorithms(self, algs: Vec<Algorithm>) -> Result<Self, AuthError>
pub fn with_algorithms(self, algs: Vec<Algorithm>) -> Result<Self, AuthError>
Replace the accepted-algorithm whitelist. Pass only algorithms
that the verifier actually supports today; the set of
supported algorithms is exposed via
crate::SUPPORTED_ALGORITHMS.
§Errors
Returns AuthError::JwtInvalid listing the unsupported entries
so misconfiguration is surfaced at construction time, not at
the first incoming token.
Sourcepub fn with_algorithms_lossy(self, algs: Vec<Algorithm>) -> Self
pub fn with_algorithms_lossy(self, algs: Vec<Algorithm>) -> Self
Lossless infallible variant: only succeeds if every entry is in
SUPPORTED_ALGORITHMS, otherwise logs a warning and falls back
to the default [EdDSA]. Use this when reading configuration
from untrusted sources where panicking on bad input is
undesirable (e.g. OIDC discovery).
pub fn with_jwks_uri(self, uri: impl Into<String>) -> Self
pub fn with_jwks_refresh(self, d: Duration) -> Self
Sourcepub fn with_jwks_refresh_from_env(self) -> Self
pub fn with_jwks_refresh_from_env(self) -> Self
Read the JWKS refresh interval from AGENTGUARD_JWKS_REFRESH
(humantime). Falls back to the default when unset or unparseable.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JwtConfig
impl RefUnwindSafe for JwtConfig
impl Send for JwtConfig
impl Sync for JwtConfig
impl Unpin 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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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