#[non_exhaustive]pub enum AuthError {
Show 22 variants
InvalidToken {
reason: String,
},
TokenExpired,
InvalidSignature,
MissingClaim {
claim: String,
},
InvalidClaimValue {
claim: String,
reason: String,
},
OAuthError {
message: String,
},
SessionError {
message: String,
},
DatabaseError {
message: String,
},
ConfigError {
message: String,
},
OidcMetadataError {
message: String,
},
PkceError {
message: String,
},
InvalidState,
TokenNotFound,
SessionRevoked,
Forbidden {
message: String,
},
Internal {
message: String,
},
SystemTimeError {
message: String,
},
RateLimited {
retry_after_secs: u64,
},
MissingNonce,
NonceMismatch,
MissingAuthTime,
SessionTooOld {
age: i64,
max_age_secs: u64,
},
}Expand description
All errors that can arise in the authentication and authorization layer.
Each variant maps to an appropriate HTTP status code via the axum::response::IntoResponse
implementation in middleware.rs. Internal details are never forwarded to API clients —
the IntoResponse impl always returns a generic user-facing message and logs the
internal reason via tracing::warn!.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidToken
A supplied token could not be parsed or validated.
The reason field contains internal diagnostic detail and must not be
sent to API clients.
TokenExpired
The token’s exp claim is in the past.
InvalidSignature
The token’s cryptographic signature did not verify against the expected key.
MissingClaim
A required JWT claim (sub, iss, aud, etc.) was absent from the token.
InvalidClaimValue
A claim was present but its value did not satisfy the validator’s constraints.
Fields
OAuthError
An error was returned by the upstream OAuth provider (e.g., during code exchange).
The message field must not be forwarded to API clients — it may contain
provider-internal URLs, error codes, or rate-limit state.
SessionError
A session-store operation failed (creation, lookup, or revocation).
DatabaseError
A database operation within the auth layer failed. Must never be forwarded to API clients — the message may reveal connection strings, query structure, or infrastructure topology.
ConfigError
The auth subsystem was misconfigured or a required configuration value was missing. Must never be forwarded to API clients — the message may reveal file paths, environment variable names, or key material.
OidcMetadataError
Fetching or parsing the OIDC discovery document failed.
PkceError
A PKCE (Proof Key for Code Exchange, RFC 7636) operation failed.
InvalidState
The OAuth state parameter did not match any stored CSRF token.
This may indicate a replay attack or an expired authorization flow.
TokenNotFound
No Authorization: Bearer <token> header was present in the request.
SessionRevoked
The session associated with a refresh token has been explicitly revoked.
Forbidden
The authenticated user lacks the required permission for the requested operation.
The message field contains the specific permission check detail and must not
be forwarded to API clients in full (it reveals internal role/permission names).
Internal
An unexpected internal error occurred. Must never be forwarded to API clients.
SystemTimeError
The system clock returned an unexpected value during a time-sensitive operation. This typically indicates a misconfigured system clock or clock rollback.
RateLimited
The client exceeded the configured rate limit for this endpoint. Unlike most other variants, the retry window is safe to forward to clients.
MissingNonce
The OIDC ID token is missing the required nonce claim.
Returned when an expected nonce was provided for comparison but the token
does not carry a nonce claim. May indicate a misconfigured provider or
a token replay attempt using a stripped token.
See RFC 6749 §10.12 / OpenID Connect Core §3.1.3.7.
NonceMismatch
The nonce claim in the ID token does not match the expected value.
Indicates a possible token replay or session fixation attack. See RFC 6749 §10.12 / OpenID Connect Core §3.1.3.7.
MissingAuthTime
The OIDC ID token is missing the auth_time claim when max_age was requested.
When max_age is sent in the authorization request, the provider MUST include
auth_time in the ID token. Its absence indicates a non-conformant provider.
See OpenID Connect Core §3.1.3.7.
SessionTooOld
The session authentication time exceeds the allowed max_age.
The provider authenticated the user too long ago for this request’s max_age
constraint. The user must re-authenticate to obtain a fresh session.
See OpenID Connect Core §3.1.3.7.
Trait Implementations§
Source§impl Error for AuthError
impl Error for AuthError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl IntoResponse for AuthError
impl IntoResponse for AuthError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for AuthError
impl RefUnwindSafe for AuthError
impl Send for AuthError
impl Sync for AuthError
impl Unpin for AuthError
impl UnsafeUnpin for AuthError
impl UnwindSafe for AuthError
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, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
MakeService which stores information
about the incoming connection and has no state. Read moreSource§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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<E> Sanitize for Ewhere
E: Display,
impl<E> Sanitize for Ewhere
E: Display,
Source§fn sanitized(self, user_message: &str) -> SanitizedError
fn sanitized(self, user_message: &str) -> SanitizedError
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.