pub struct OAuth2Config {Show 14 fields
pub registration_id: String,
pub client_id: String,
pub client_secret: String,
pub redirect_uri: String,
pub provider: OAuth2Provider,
pub authorization_uri: Option<String>,
pub token_uri: Option<String>,
pub userinfo_uri: Option<String>,
pub issuer_uri: Option<String>,
pub jwk_set_uri: Option<String>,
pub scopes: Vec<String>,
pub use_pkce: bool,
pub authorization_params: HashMap<String, String>,
pub username_attribute: String,
}Expand description
Fields§
§registration_id: StringRegistration ID (e.g., “google”, “github”)
client_id: StringOAuth2 client ID
client_secret: StringOAuth2 client secret
redirect_uri: StringRedirect URI for callbacks
provider: OAuth2ProviderOAuth2 provider
Authorization endpoint URL (optional, auto-discovered for OIDC)
token_uri: Option<String>Token endpoint URL (optional, auto-discovered for OIDC)
userinfo_uri: Option<String>User info endpoint URL (optional, auto-discovered for OIDC)
issuer_uri: Option<String>OIDC issuer URL (for discovery)
jwk_set_uri: Option<String>JWK Set URI (for ID token validation)
scopes: Vec<String>OAuth2 scopes
use_pkce: boolUse PKCE (Proof Key for Code Exchange)
Custom parameters for authorization request
username_attribute: StringAttribute name for username extraction
Implementations§
Source§impl OAuth2Config
impl OAuth2Config
Sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>,
redirect_uri: impl Into<String>,
) -> Self
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String>, redirect_uri: impl Into<String>, ) -> Self
Create a new OAuth2 configuration
§Arguments
client_id- The OAuth2 client IDclient_secret- The OAuth2 client secretredirect_uri- The callback URL for authorization response
Sourcepub fn registration_id(self, id: impl Into<String>) -> Self
pub fn registration_id(self, id: impl Into<String>) -> Self
Set the registration ID
Sourcepub fn provider(self, provider: OAuth2Provider) -> Self
pub fn provider(self, provider: OAuth2Provider) -> Self
Set the OAuth2 provider
This will auto-configure endpoints for known providers.
Set the authorization endpoint URL
Sourcepub fn userinfo_uri(self, uri: impl Into<String>) -> Self
pub fn userinfo_uri(self, uri: impl Into<String>) -> Self
Set the user info endpoint URL
Sourcepub fn issuer_uri(self, uri: impl Into<String>) -> Self
pub fn issuer_uri(self, uri: impl Into<String>) -> Self
Set the OIDC issuer URL for auto-discovery
Sourcepub fn jwk_set_uri(self, uri: impl Into<String>) -> Self
pub fn jwk_set_uri(self, uri: impl Into<String>) -> Self
Set the JWK Set URI for ID token validation
Add a custom authorization parameter
Sourcepub fn username_attribute(self, attr: impl Into<String>) -> Self
pub fn username_attribute(self, attr: impl Into<String>) -> Self
Set the attribute name used for extracting the username
Trait Implementations§
Source§impl Clone for OAuth2Config
impl Clone for OAuth2Config
Source§fn clone(&self) -> OAuth2Config
fn clone(&self) -> OAuth2Config
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OAuth2Config
impl RefUnwindSafe for OAuth2Config
impl Send for OAuth2Config
impl Sync for OAuth2Config
impl Unpin for OAuth2Config
impl UnwindSafe for OAuth2Config
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,
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