pub struct OAuth2ResourceServerBuilder<Claims>{ /* private fields */ }Implementations§
Source§impl<Claims> OAuth2ResourceServerBuilder<Claims>
impl<Claims> OAuth2ResourceServerBuilder<Claims>
Sourcepub fn issuer_url(self, issuer_url: impl Into<String>) -> Self
pub fn issuer_url(self, issuer_url: impl Into<String>) -> Self
Set the issuer_url (what authorization server to use).
On startup, the OIDC Provider Configuration endpoint of the authorization server will be queried in order to self-configure the middleware.
If issuer_url is set to https://authorization-server.com/issuer,
at least one of the following endpoints need to available.
https://authorization-server.com/issuer/.well-known/openid-configurationhttps://authorization-server.com/.well-known/openid-configuration/issuerhttps://authorization-server.com/.well-known/oauth-authorization-server/issuer
A consequence of the self-configuration is that the authorization server
must be available when the middleware is started.
In cases where the middleware must be able to start independently from
the authorization server, the jwks_url property can be set.
This will prevent the self-configuration on start up.
Note that it’s still required to provide issuer_url
because it’s used to validate iss claim of JWTs.
Sourcepub fn jwks_url(self, jwks_url: impl Into<String>) -> Self
pub fn jwks_url(self, jwks_url: impl Into<String>) -> Self
Set the jwks_url (what url to query valid public keys from).
This url is normally fetched by calling the OIDC Provider Configuration endpoint of the authorization server. Only provide this property if the middleware must be able to start independently from the authorization server.
Sourcepub fn audiences(self, audiences: &[impl ToString]) -> Self
pub fn audiences(self, audiences: &[impl ToString]) -> Self
Set the expected audiences.
Used to validate aud claim of JWTs.
Sourcepub fn jwks_refresh_interval(self, jwk_set_refresh_interval: Duration) -> Self
pub fn jwks_refresh_interval(self, jwk_set_refresh_interval: Duration) -> Self
Set the interval for rotating jwks.
The jwks_url is periodically queried in order to update
public keys that JWT signatures will be validated against.
Default value is Duration::from_secs(60).
Sourcepub fn claims_validation(self, claims_validation: ClaimsValidationSpec) -> Self
pub fn claims_validation(self, claims_validation: ClaimsValidationSpec) -> Self
Set what claims of JWTs to validate.
By default, iss, exp, aud and possibly nbf will be validated.
Sourcepub async fn build(self) -> Result<OAuth2ResourceServer<Claims>, StartupError>
pub async fn build(self) -> Result<OAuth2ResourceServer<Claims>, StartupError>
Construct an OAuth2ResourceServer.
During construction the OIDC Provider Configuration endpoint of the authorization server might be queried. Thus, the operation can fail and therefore returns a Result.