pub struct ExternalAuthClient { /* private fields */ }Expand description
External-mode AuthClient that validates RS256 JWTs locally and talks to the allowthem server for code exchange.
Cheap to clone (Arc internals).
Implementations§
Source§impl ExternalAuthClient
impl ExternalAuthClient
Sourcepub fn builder(
base_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
redirect_uri: impl Into<String>,
login_url: impl Into<String>,
) -> ExternalAuthClientBuilder
pub fn builder( base_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, redirect_uri: impl Into<String>, login_url: impl Into<String>, ) -> ExternalAuthClientBuilder
Shorthand for ExternalAuthClientBuilder::new(...).
Generate PKCE challenge and state for an authorization request.
Returns the full authorize URL and the AuthorizeRequest containing
the code_verifier and state for later verification.
Sourcepub async fn exchange_code(
&self,
code: &str,
code_verifier: &str,
redirect_uri: &str,
) -> Result<TokenExchangeResponse, AuthError>
pub async fn exchange_code( &self, code: &str, code_verifier: &str, redirect_uri: &str, ) -> Result<TokenExchangeResponse, AuthError>
Exchange an authorization code for tokens.
Trait Implementations§
Source§impl AuthClient for ExternalAuthClient
impl AuthClient for ExternalAuthClient
Source§fn validate_session<'a>(
&'a self,
token: &'a SessionToken,
) -> AuthFuture<'a, Option<User>>
fn validate_session<'a>( &'a self, token: &'a SessionToken, ) -> AuthFuture<'a, Option<User>>
Validate a session token and return the active user. Read more
Source§fn check_role<'a>(
&'a self,
user_id: &'a UserId,
role: &'a RoleName,
) -> AuthFuture<'a, bool>
fn check_role<'a>( &'a self, user_id: &'a UserId, role: &'a RoleName, ) -> AuthFuture<'a, bool>
Check whether a user has the given role.
Source§fn check_permission<'a>(
&'a self,
user_id: &'a UserId,
permission: &'a PermissionName,
) -> AuthFuture<'a, bool>
fn check_permission<'a>( &'a self, user_id: &'a UserId, permission: &'a PermissionName, ) -> AuthFuture<'a, bool>
Check whether a user has the given permission (direct or via role).
Source§fn resolve_highest_role<'a>(
&'a self,
user_id: &'a UserId,
hierarchy: &'a [&str],
) -> AuthFuture<'a, Option<String>>
fn resolve_highest_role<'a>( &'a self, user_id: &'a UserId, hierarchy: &'a [&str], ) -> AuthFuture<'a, Option<String>>
Return the name of the first role in
hierarchy that the user holds. Read moreSource§fn logout<'a>(&'a self, token: &'a SessionToken) -> AuthFuture<'a, ()>
fn logout<'a>(&'a self, token: &'a SessionToken) -> AuthFuture<'a, ()>
Invalidate a session. Fire-and-forget — non-existent sessions are not errors.
The cookie name used for session tokens.
Source§impl Clone for ExternalAuthClient
impl Clone for ExternalAuthClient
Source§fn clone(&self) -> ExternalAuthClient
fn clone(&self) -> ExternalAuthClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ExternalAuthClient
impl !UnwindSafe for ExternalAuthClient
impl Freeze for ExternalAuthClient
impl Send for ExternalAuthClient
impl Sync for ExternalAuthClient
impl Unpin for ExternalAuthClient
impl UnsafeUnpin for ExternalAuthClient
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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