pub struct JwtVerifierBuilder { /* private fields */ }Expand description
Builder of JwtVerifier.
Implementations§
Source§impl JwtVerifierBuilder
impl JwtVerifierBuilder
Sourcepub fn jwks_uri(self, uri: impl Into<String>) -> Self
pub fn jwks_uri(self, uri: impl Into<String>) -> Self
Fetches keys from this URL instead of discovering it from the issuer’s metadata.
Sourcepub fn jwks(self, document: impl Into<String>) -> Self
pub fn jwks(self, document: impl Into<String>) -> Self
Uses these keys (a JWKS document, {"keys": [..]}) and never fetches
any. Rotating them then requires a restart.
Sourcepub fn algorithms(self, algorithms: impl IntoIterator<Item = Algorithm>) -> Self
pub fn algorithms(self, algorithms: impl IntoIterator<Item = Algorithm>) -> Self
The accepted signature algorithms. Default: all of Algorithm::ALL.
Sourcepub fn leeway(self, leeway: Duration) -> Self
pub fn leeway(self, leeway: Duration) -> Self
Tolerated clock difference for exp and nbf. Default: 60 s.
Sourcepub fn http_timeout(self, timeout: Duration) -> Self
pub fn http_timeout(self, timeout: Duration) -> Self
Time allowed for each metadata or JWKS request. Default: 5 s.
Sourcepub fn min_refresh_interval(self, interval: Duration) -> Self
pub fn min_refresh_interval(self, interval: Duration) -> Self
Minimum time between two key fetches triggered by tokens that name unknown keys, so forged tokens cannot make the server hammer the authorization server. Default: 30 s.
Sourcepub fn build(self) -> Result<JwtVerifier, JwtError>
pub fn build(self) -> Result<JwtVerifier, JwtError>
Validates the settings.
§Errors
Fails when the issuer or jwks_uri is not a valid URL (https, or
http on localhost), the audience is empty, no algorithm is allowed,
static keys contain no usable signing key, or the system’s TLS roots
cannot be loaded.