pub struct AuthHandler { /* private fields */ }Expand description
Authentication handler
Implementations§
Source§impl AuthHandler
impl AuthHandler
Sourcepub fn new(config: AuthConfig) -> Self
pub fn new(config: AuthConfig) -> Self
Create a new auth handler with the given configuration
Sourcepub fn from_config_with_env(config: AuthConfig) -> Self
pub fn from_config_with_env(config: AuthConfig) -> Self
Load configuration with environment variable overrides
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if authentication is enabled
Sourcepub fn is_protected(&self, path: &str) -> bool
pub fn is_protected(&self, path: &str) -> bool
Check if a path is protected
Sourcepub fn login_path(&self) -> &str
pub fn login_path(&self) -> &str
Get the login path
Sourcepub fn after_login_path(&self) -> &str
pub fn after_login_path(&self) -> &str
Get the after-login redirect path
Sourcepub fn login_endpoint(&self) -> Option<&str>
pub fn login_endpoint(&self) -> Option<&str>
Get the login endpoint URL
Sourcepub fn logout_endpoint(&self) -> Option<&str>
pub fn logout_endpoint(&self) -> Option<&str>
Get the logout endpoint URL
Get the JWT cookie name
Sourcepub fn jwt_claims(&self) -> &[String]
pub fn jwt_claims(&self) -> &[String]
Get the list of claims to extract
Parse JWT from cookie header
Sourcepub fn decode_jwt(&self, token: &str) -> Result<JwtClaims>
pub fn decode_jwt(&self, token: &str) -> Result<JwtClaims>
Decode and validate a JWT token.
Always validates the signature. If no jwt_secret is configured, a random secret is generated at startup (logged as WARN). This means externally-signed tokens will be rejected unless the correct secret is provided.
Build Set-Cookie header for JWT token
Build Set-Cookie header to clear the JWT cookie
Trait Implementations§
Source§impl Clone for AuthHandler
impl Clone for AuthHandler
Source§fn clone(&self) -> AuthHandler
fn clone(&self) -> AuthHandler
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 Freeze for AuthHandler
impl RefUnwindSafe for AuthHandler
impl Send for AuthHandler
impl Sync for AuthHandler
impl Unpin for AuthHandler
impl UnsafeUnpin for AuthHandler
impl UnwindSafe for AuthHandler
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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