pub struct OAuthProviderConfig {
pub name: Arc<str>,
pub scopes: Vec<String>,
pub ceremony_timeout: Duration,
/* private fields */
}oauth only.Expand description
Configuration for an OAuth 2.0 / OIDC identity provider.
Fields§
§name: Arc<str>Short identifier for this provider (e.g. "google", "github").
scopes: Vec<String>Scopes to request. Default: ["openid", "email", "profile"].
ceremony_timeout: DurationHow long the OAuth ceremony (redirect → callback) is valid. Default: 10 minutes. Set higher for IdPs with slow MFA prompts.
Implementations§
Source§impl OAuthProviderConfig
impl OAuthProviderConfig
Sourcepub fn with_scopes(self, scopes: Vec<String>) -> OAuthProviderConfig
pub fn with_scopes(self, scopes: Vec<String>) -> OAuthProviderConfig
Override the default scopes.
Sourcepub fn with_ceremony_timeout(self, timeout: Duration) -> OAuthProviderConfig
pub fn with_ceremony_timeout(self, timeout: Duration) -> OAuthProviderConfig
Override the ceremony timeout (default: 10 minutes).
Sourcepub fn with_fapi(
self,
config: FapiConfig,
) -> Result<OAuthProviderConfig, OAuthError>
pub fn with_fapi( self, config: FapiConfig, ) -> Result<OAuthProviderConfig, OAuthError>
Enable FAPI 2.0 Baseline Profile for this provider.
Enforces: mandatory PAR, sender-constrained tokens (DPoP or MTLS),
and stricter ID token lifetime validation. Requires the IdP to
advertise a pushed_authorization_request_endpoint in discovery.
Sourcepub fn with_par_endpoint(self, url: impl Into<String>) -> OAuthProviderConfig
pub fn with_par_endpoint(self, url: impl Into<String>) -> OAuthProviderConfig
Manually set the PAR endpoint (RFC 9126).
Only needed if the IdP doesn’t advertise it in OIDC discovery metadata.
Sourcepub fn with_revocation_endpoint(
self,
url: impl Into<String>,
) -> OAuthProviderConfig
pub fn with_revocation_endpoint( self, url: impl Into<String>, ) -> OAuthProviderConfig
Manually set the OAuth 2.0 token revocation endpoint (RFC 7009).
Only needed when the IdP exposes a revocation endpoint but does
not advertise it in the standard OIDC discovery metadata under
the revocation_endpoint field; discover() then leaves
revoke_token returning Config("...does not include a revocation_endpoint"). Use this setter to override.
Sourcepub fn with_end_session_endpoint(
self,
url: impl Into<String>,
) -> OAuthProviderConfig
pub fn with_end_session_endpoint( self, url: impl Into<String>, ) -> OAuthProviderConfig
Manually set the OIDC RP-Initiated Logout endpoint
(end_session_endpoint).
Same rationale as with_revocation_endpoint:
many IdPs expose the endpoint without advertising it in
discovery, so build_end_session_url
returns None until the URL is supplied.
Sourcepub fn with_allowed_post_logout_redirect_uris(
self,
uris: impl IntoIterator<Item = impl Into<String>>,
) -> OAuthProviderConfig
pub fn with_allowed_post_logout_redirect_uris( self, uris: impl IntoIterator<Item = impl Into<String>>, ) -> OAuthProviderConfig
Configure the set of post_logout_redirect_uri values accepted by
build_end_session_url. Each entry must match exactly (no glob /
substring matching); values not in the list are silently dropped
before being passed to the IdP, defeating phishing chains where an
attacker tricks a user-controlled redirect parameter through the
logout flow.
Set the device authorization endpoint URL (RFC 8628).
Required for the device code flow. Not part of standard OIDC discovery; check your IdP’s documentation for the URL.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> OAuthProviderConfig
pub fn with_clock(self, clock: Arc<dyn Clock>) -> OAuthProviderConfig
Swap the clock used for FAPI nbf / clock-skew checks. Defaults
to SystemClock. Pass a
MockClock under DST so the
time-bound validation is deterministic.
Source§impl OAuthProviderConfig
impl OAuthProviderConfig
Sourcepub async fn discover(
name: &str,
issuer_url: &str,
client_id: &str,
client_secret: &str,
redirect_url: &str,
) -> Result<OAuthProviderConfig, OAuthError>
pub async fn discover( name: &str, issuer_url: &str, client_id: &str, client_secret: &str, redirect_url: &str, ) -> Result<OAuthProviderConfig, OAuthError>
Create a provider using OIDC discovery.
Fetches {issuer_url}/.well-known/openid-configuration to configure
authorization, token, and userinfo endpoints automatically.
Source§impl OAuthProviderConfig
impl OAuthProviderConfig
Sourcepub async fn refresh_jwks(&self) -> Result<(), OAuthError>
pub async fn refresh_jwks(&self) -> Result<(), OAuthError>
Re-fetch the IdP’s JWKS via JwksCache::refresh.
Called automatically by the back-channel logout handler when a kid is
not found in the cached JWKS (IdP key rotation). Can also be called
proactively on a schedule.
Trait Implementations§
Source§impl OAuthProvider for OAuthProviderConfig
impl OAuthProvider for OAuthProviderConfig
Source§fn issuer(&self) -> Option<&str>
fn issuer(&self) -> Option<&str>
"https://accounts.google.com").Source§fn ceremony_timeout(&self) -> Duration
fn ceremony_timeout(&self) -> Duration
Source§fn refresh_jwks<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<(), OAuthError>> + Send + 'a>>
fn refresh_jwks<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<(), OAuthError>> + Send + 'a>>
jwks_uri.Source§fn verify_logout_jwt(&self, token: &str) -> Result<Value, OAuthError>
fn verify_logout_jwt(&self, token: &str) -> Result<Value, OAuthError>
Source§fn fetch_userinfo<'a>(
&'a self,
access_token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<UserInfoClaims, OAuthError>> + Send + 'a>>
fn fetch_userinfo<'a>( &'a self, access_token: &'a str, ) -> Pin<Box<dyn Future<Output = Result<UserInfoClaims, OAuthError>> + Send + 'a>>
Source§fn refresh_token<'a>(
&'a self,
refresh_token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<OAuthClaims, OAuthError>> + Send + 'a>>
fn refresh_token<'a>( &'a self, refresh_token: &'a str, ) -> Pin<Box<dyn Future<Output = Result<OAuthClaims, OAuthError>> + Send + 'a>>
Source§fn exchange_code<'a>(
&'a self,
code: &'a str,
pkce_verifier: String,
nonce: String,
) -> Pin<Box<dyn Future<Output = Result<OAuthClaims, OAuthError>> + Send + 'a>>
fn exchange_code<'a>( &'a self, code: &'a str, pkce_verifier: String, nonce: String, ) -> Pin<Box<dyn Future<Output = Result<OAuthClaims, OAuthError>> + Send + 'a>>
Source§fn build_auth_url(
&self,
options: &OAuthLoginOptions,
) -> Result<(Url, String, String, String), OAuthError>
fn build_auth_url( &self, options: &OAuthLoginOptions, ) -> Result<(Url, String, String, String), OAuthError>
Source§fn build_auth_url_par<'a>(
&'a self,
options: &'a OAuthLoginOptions,
) -> Pin<Box<dyn Future<Output = Result<(Url, String, String, String), OAuthError>> + Send + 'a>>
fn build_auth_url_par<'a>( &'a self, options: &'a OAuthLoginOptions, ) -> Pin<Box<dyn Future<Output = Result<(Url, String, String, String), OAuthError>> + Send + 'a>>
Source§fn fapi_config(&self) -> Option<&FapiConfig>
fn fapi_config(&self) -> Option<&FapiConfig>
Source§fn generate_dpop_proof(
&self,
http_method: &str,
http_url: &str,
access_token: Option<&str>,
key_seed: [u8; 32],
) -> Result<DpopProof, OAuthError>
fn generate_dpop_proof( &self, http_method: &str, http_url: &str, access_token: Option<&str>, key_seed: [u8; 32], ) -> Result<DpopProof, OAuthError>
Source§fn build_end_session_url(
&self,
id_token_hint: Option<&str>,
post_logout_redirect_uri: Option<&str>,
state: Option<&str>,
) -> Option<Url>
fn build_end_session_url( &self, id_token_hint: Option<&str>, post_logout_redirect_uri: Option<&str>, state: Option<&str>, ) -> Option<Url>
Source§fn revoke_token<'a>(
&'a self,
token: &'a str,
token_type_hint: Option<&'a str>,
) -> Pin<Box<dyn Future<Output = Result<(), OAuthError>> + Send + 'a>>
fn revoke_token<'a>( &'a self, token: &'a str, token_type_hint: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<(), OAuthError>> + Send + 'a>>
Source§fn client_credentials<'a>(
&'a self,
scopes: &'a [&'a str],
) -> Pin<Box<dyn Future<Output = Result<ClientCredentialsToken, OAuthError>> + Send + 'a>>
fn client_credentials<'a>( &'a self, scopes: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<ClientCredentialsToken, OAuthError>> + Send + 'a>>
Source§fn request_device_code<'a>(
&'a self,
scopes: &'a [&'a str],
) -> Pin<Box<dyn Future<Output = Result<DeviceAuthResponse, OAuthError>> + Send + 'a>>
fn request_device_code<'a>( &'a self, scopes: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<DeviceAuthResponse, OAuthError>> + Send + 'a>>
Source§fn poll_device_token<'a>(
&'a self,
device_code: &'a str,
current_interval: u64,
nonce: Option<&'a str>,
) -> Pin<Box<dyn Future<Output = Result<DeviceTokenOutcome, OAuthError>> + Send + 'a>>
fn poll_device_token<'a>( &'a self, device_code: &'a str, current_interval: u64, nonce: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<DeviceTokenOutcome, OAuthError>> + Send + 'a>>
Auto Trait Implementations§
impl Freeze for OAuthProviderConfig
impl !RefUnwindSafe for OAuthProviderConfig
impl Send for OAuthProviderConfig
impl Sync for OAuthProviderConfig
impl Unpin for OAuthProviderConfig
impl UnsafeUnpin for OAuthProviderConfig
impl !UnwindSafe for OAuthProviderConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.