pub enum AuthError {
Show 43 variants
Configuration {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
help: Option<String>,
docs_url: Option<String>,
suggested_fix: Option<String>,
},
AuthMethod {
method: String,
message: String,
help: Option<String>,
docs_url: Option<String>,
suggested_fix: Option<String>,
},
Token(TokenError),
Permission(PermissionError),
Storage(StorageError),
Network(Error),
Json(Error),
Jwt(Error),
Yaml(Error),
Toml(Error),
Io(Error),
Cli(String),
SystemTime(SystemTimeError),
RateLimit {
message: String,
},
TooManyConcurrentSessions,
Mfa(MfaError),
DeviceFlow(DeviceFlowError),
OAuthProvider(OAuthProviderError),
PasswordVerification(String),
PasswordHashing(String),
UserNotFound,
InvalidInput(String),
HardwareToken(String),
BackupCodeVerification(String),
BackupCodeHashing(String),
InvalidSecret,
UserProfile {
message: String,
},
InvalidCredential {
credential_type: String,
message: String,
},
Timeout {
timeout_seconds: u64,
},
ProviderNotConfigured {
provider: String,
},
Crypto {
message: String,
},
Validation {
message: String,
},
Internal {
message: String,
},
InvalidRequest(String),
StepUpRequired {
current_level: String,
required_level: String,
step_up_url: String,
},
SessionError(String),
Unauthorized(String),
TokenGeneration(String),
InvalidToken(String),
UnsupportedProvider(String),
NetworkError(String),
ParseError(String),
ConfigurationError(String),
}
Expand description
Comprehensive error type covering all authentication and authorization failures.
AuthError
provides detailed error information for all aspects of the authentication
framework, from configuration issues to runtime failures. Each error variant includes
contextual information to aid in debugging and provide appropriate user feedback.
This enhanced error type provides:
- Actionable error messages with specific suggestions for fixes
- Documentation links to relevant guides and troubleshooting
- Contextual help that guides users to solutions
- Security-aware messaging that doesnโt leak sensitive information
ยงError Categories
ยงConfiguration Errors
Errors that occur during framework setup and configuration validation.
ยงAuthentication Errors
Errors related to credential validation and authentication method execution.
ยงAuthorization Errors
Errors related to permission checking and access control.
ยงToken Errors
JWT token creation, validation, expiration, and lifecycle issues.
ยงStorage Errors
Database connectivity, query failures, and data persistence issues.
ยงNetwork Errors
External service communication, timeouts, and connectivity problems.
ยงCryptographic Errors
Encryption, decryption, signing, and other security operation failures.
ยงEnhanced Error Handling
use auth_framework::AuthError;
// Enhanced error handling with contextual help
match auth_result {
Err(AuthError::Configuration { message, help, docs_url, .. }) => {
eprintln!("โ Configuration Error: {}", message);
if let Some(help) = help {
eprintln!("๐ก Help: {}", help);
}
if let Some(docs) = docs_url {
eprintln!("๐ See: {}", docs);
}
},
Err(AuthError::InvalidCredential { credential_type, message, suggested_fix, .. }) => {
eprintln!("๐ Invalid {}: {}", credential_type, message);
if let Some(fix) = suggested_fix {
eprintln!("๐ง Suggested fix: {}", fix);
}
},
// ... handle other error types
}
ยงSecurity Notes
Error messages are carefully crafted to:
- Provide sufficient detail for debugging and monitoring
- Avoid exposing sensitive information that could aid attackers
- Enable security teams to identify potential threats
- Support compliance and audit requirements
- Guide users to secure solutions and best practices
Variantsยง
Configuration
Configuration validation and setup errors.
These errors occur when the authentication framework is misconfigured or when configuration validation fails during startup.
Fields
AuthMethod
Authentication method execution errors.
These errors occur when a specific authentication method fails to execute properly, such as OAuth provider communication failures.
Fields
Token(TokenError)
Token-related errors
Permission(PermissionError)
Permission-related errors
Storage(StorageError)
Storage-related errors
Network(Error)
Network/HTTP errors
Json(Error)
JSON parsing errors
Jwt(Error)
JWT errors
Yaml(Error)
YAML parsing errors
Toml(Error)
TOML parsing errors
Io(Error)
IO errors
Cli(String)
CLI interaction errors
SystemTime(SystemTimeError)
System time errors
RateLimit
Rate limiting errors
TooManyConcurrentSessions
Session-related errors
Mfa(MfaError)
MFA-related errors
DeviceFlow(DeviceFlowError)
Device flow errors
OAuthProvider(OAuthProviderError)
OAuth provider errors
PasswordVerification(String)
Password verification errors
PasswordHashing(String)
Password hashing errors
UserNotFound
User not found error
InvalidInput(String)
Invalid input error
HardwareToken(String)
Hardware token errors
BackupCodeVerification(String)
Backup code verification errors
BackupCodeHashing(String)
Backup code hashing errors
InvalidSecret
Invalid secret error
UserProfile
User profile errors
InvalidCredential
Credential validation errors
Timeout
Authentication timeout
ProviderNotConfigured
Provider configuration missing
Crypto
Cryptography errors
Validation
Validation errors
Internal
Generic internal errors
InvalidRequest(String)
Invalid request error
StepUpRequired
Step-up authentication required
SessionError(String)
Session error
Unauthorized access
TokenGeneration(String)
Token generation error
InvalidToken(String)
Invalid token error
UnsupportedProvider(String)
Unsupported provider error
NetworkError(String)
Network error with custom message
ParseError(String)
Parse error with custom message
ConfigurationError(String)
Configuration error with custom message
Implementationsยง
Sourceยงimpl AuthError
impl AuthError
Sourcepub fn config_with_help(
message: impl Into<String>,
help: impl Into<String>,
suggested_fix: Option<String>,
) -> Self
pub fn config_with_help( message: impl Into<String>, help: impl Into<String>, suggested_fix: Option<String>, ) -> Self
Create a configuration error with helpful context
Sourcepub fn jwt_secret_too_short(current_length: usize) -> Self
pub fn jwt_secret_too_short(current_length: usize) -> Self
Create a JWT secret validation error with helpful guidance
Sourcepub fn production_memory_storage() -> Self
pub fn production_memory_storage() -> Self
Create a production environment error with guidance
Sourcepub fn auth_method(
method: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn auth_method( method: impl Into<String>, message: impl Into<String>, ) -> Self
Create a new auth method error
Sourcepub fn auth_method_with_help(
method: impl Into<String>,
message: impl Into<String>,
help: impl Into<String>,
suggested_fix: Option<String>,
) -> Self
pub fn auth_method_with_help( method: impl Into<String>, message: impl Into<String>, help: impl Into<String>, suggested_fix: Option<String>, ) -> Self
Create an auth method error with helpful context
Sourcepub fn rate_limit(message: impl Into<String>) -> Self
pub fn rate_limit(message: impl Into<String>) -> Self
Create a new rate limit error
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a new validation error
Create an authorization error
Sourcepub fn access_denied(message: impl Into<String>) -> Self
pub fn access_denied(message: impl Into<String>) -> Self
Create an access denied error
Sourcepub fn device_flow(error: DeviceFlowError) -> Self
pub fn device_flow(error: DeviceFlowError) -> Self
Create a device flow error
Sourcepub fn oauth_provider(error: OAuthProviderError) -> Self
pub fn oauth_provider(error: OAuthProviderError) -> Self
Create an OAuth provider error
Sourcepub fn user_profile(message: impl Into<String>) -> Self
pub fn user_profile(message: impl Into<String>) -> Self
Create a user profile error
Sourcepub fn invalid_credential(
credential_type: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn invalid_credential( credential_type: impl Into<String>, message: impl Into<String>, ) -> Self
Create an invalid credential error
Sourcepub fn provider_not_configured(provider: impl Into<String>) -> Self
pub fn provider_not_configured(provider: impl Into<String>) -> Self
Create a provider not configured error
Sourcepub fn rate_limited(message: impl Into<String>) -> Self
pub fn rate_limited(message: impl Into<String>) -> Self
Create a rate limited error
Sourcepub fn configuration(message: impl Into<String>) -> Self
pub fn configuration(message: impl Into<String>) -> Self
Create a configuration error
Trait Implementationsยง
Sourceยงimpl Error for AuthError
impl Error for AuthError
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
Sourceยงimpl From<DeviceFlowError> for AuthError
impl From<DeviceFlowError> for AuthError
Sourceยงfn from(source: DeviceFlowError) -> Self
fn from(source: DeviceFlowError) -> Self
Sourceยงimpl From<OAuthProviderError> for AuthError
impl From<OAuthProviderError> for AuthError
Sourceยงfn from(source: OAuthProviderError) -> Self
fn from(source: OAuthProviderError) -> Self
Sourceยงimpl From<PermissionError> for AuthError
impl From<PermissionError> for AuthError
Sourceยงfn from(source: PermissionError) -> Self
fn from(source: PermissionError) -> Self
Sourceยงimpl From<StorageError> for AuthError
impl From<StorageError> for AuthError
Sourceยงfn from(source: StorageError) -> Self
fn from(source: StorageError) -> Self
Sourceยงimpl From<SystemTimeError> for AuthError
impl From<SystemTimeError> for AuthError
Sourceยงfn from(source: SystemTimeError) -> Self
fn from(source: SystemTimeError) -> Self
Sourceยงimpl From<TokenError> for AuthError
impl From<TokenError> for AuthError
Sourceยงfn from(source: TokenError) -> Self
fn from(source: TokenError) -> Self
Auto Trait Implementationsยง
impl Freeze for AuthError
impl !RefUnwindSafe for AuthError
impl Send for AuthError
impl Sync for AuthError
impl Unpin for AuthError
impl !UnwindSafe for AuthError
Blanket Implementationsยง
Sourceยงimpl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Sourceยงimpl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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<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.