pub struct OAuth2Gate<R, G>where
R: AccessHierarchy + Eq + Display + Send + Sync + 'static,
G: Eq + Clone + Send + Sync + 'static,{ /* private fields */ }Expand description
Public builder for configuring OAuth2 routes and session issuance.
Implementations§
Source§impl<R, G> OAuth2Gate<R, G>
impl<R, G> OAuth2Gate<R, G>
Sourcepub fn client_secret(self, secret: impl Into<String>) -> Self
pub fn client_secret(self, secret: impl Into<String>) -> Self
Set the OAuth2 client secret (optional for public clients).
Sourcepub fn redirect_url(self, url: impl Into<String>) -> Self
pub fn redirect_url(self, url: impl Into<String>) -> Self
Set the redirect URL that your provider will call after user authorization.
Sourcepub fn add_scope(self, scope: impl Into<String>) -> Self
pub fn add_scope(self, scope: impl Into<String>) -> Self
Add a scope to request from the provider.
Set custom cookie names for state/PKCE (primarily for multi-provider setups).
This also updates the underlying cookie templates to use the provided names.
Configure the state cookie template directly.
Convenience to configure the state cookie template via the high-level builder.
Configure the PKCE cookie template directly.
Convenience to configure the PKCE cookie template via the high-level builder.
Configure the auth cookie template used to store the first-party JWT.
Convenience to configure the auth cookie template via the high-level builder.
Sourcepub fn with_post_login_redirect(self, url: impl Into<String>) -> Self
pub fn with_post_login_redirect(self, url: impl Into<String>) -> Self
Configure a post-login redirect URL (e.g., “/”).
Sourcepub fn with_account_mapper<F>(self, f: F) -> Selfwhere
for<'a> F: Send + Sync + 'static + Fn(&'a StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>) -> Pin<Box<dyn Future<Output = OAuth2Result<Account<R, G>>> + Send + 'a>>,
pub fn with_account_mapper<F>(self, f: F) -> Selfwhere
for<'a> F: Send + Sync + 'static + Fn(&'a StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>) -> Pin<Box<dyn Future<Output = OAuth2Result<Account<R, G>>> + Send + 'a>>,
Provide an async account mapper that converts the token response to an Account<R, G>.
This allows performing async I/O (e.g., calling a provider user info endpoint) without blocking.
Sourcepub fn with_account_inserter<F, Fut>(self, f: F) -> Self
pub fn with_account_inserter<F, Fut>(self, f: F) -> Self
Provide an async account inserter that persists or loads an account before JWT issuance.
The closure is called after mapping the provider token to an Account and before encoding the JWT. It should return the persisted or loaded Account (with a stable account_id).
Sourcepub fn with_account_repository<AccRepo>(
self,
account_repository: Arc<AccRepo>,
) -> Self
pub fn with_account_repository<AccRepo>( self, account_repository: Arc<AccRepo>, ) -> Self
Convenience: insert into an AccountRepository on first login (idempotent).
Queries by user_id; if missing, stores the provided account. Returns the existing or stored account.
Sourcepub fn with_jwt_codec<C>(
self,
issuer: &str,
codec: Arc<C>,
ttl_secs: u64,
) -> Self
pub fn with_jwt_codec<C>( self, issuer: &str, codec: Arc<C>, ttl_secs: u64, ) -> Self
Provide a JWT codec and issuer; sets up a type-erased encoder closure.
This helper uses your provided codec to mint a first-party session JWT from an Account<R, G>. The ttl_secs here sets expiry and overrides with_jwt_ttl_secs.
Trait Implementations§
Source§impl<R, G> Clone for OAuth2Gate<R, G>
impl<R, G> Clone for OAuth2Gate<R, G>
Source§fn clone(&self) -> OAuth2Gate<R, G>
fn clone(&self) -> OAuth2Gate<R, G>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R, G> Debug for OAuth2Gate<R, G>
impl<R, G> Debug for OAuth2Gate<R, G>
Auto Trait Implementations§
impl<R, G> Freeze for OAuth2Gate<R, G>
impl<R, G> !RefUnwindSafe for OAuth2Gate<R, G>
impl<R, G> Send for OAuth2Gate<R, G>
impl<R, G> Sync for OAuth2Gate<R, G>
impl<R, G> Unpin for OAuth2Gate<R, G>
impl<R, G> !UnwindSafe for OAuth2Gate<R, G>
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