armature_auth/
error.rs

1// Error types for authentication
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum AuthError {
7    #[error("Authentication failed: {0}")]
8    AuthenticationFailed(String),
9
10    #[error("Invalid credentials")]
11    InvalidCredentials,
12
13    #[error("User not found")]
14    UserNotFound,
15
16    #[error("User inactive")]
17    InactiveUser,
18
19    #[error("Unauthorized")]
20    Unauthorized,
21
22    #[error("Forbidden: {0}")]
23    Forbidden(String),
24
25    #[error("Invalid token: {0}")]
26    InvalidToken(String),
27
28    #[error("Token expired")]
29    TokenExpired,
30
31    #[error("Password hashing error: {0}")]
32    PasswordHashError(String),
33
34    #[error("Password verification error: {0}")]
35    PasswordVerifyError(String),
36
37    #[error("JWT error: {0}")]
38    JwtError(#[from] armature_jwt::JwtError),
39
40    #[error("Missing required role: {0}")]
41    MissingRole(String),
42
43    #[error("Missing permission: {0}")]
44    MissingPermission(String),
45
46    #[error("Configuration error: {0}")]
47    Configuration(String),
48
49    #[error("HTTP request error: {0}")]
50    HttpRequest(String),
51
52    #[error("Invalid response: {0}")]
53    InvalidResponse(String),
54
55    #[error("API key error: {0}")]
56    ApiKeyError(String),
57
58    #[error("Two-factor authentication error: {0}")]
59    TwoFactorError(String),
60
61    #[error("Passwordless auth error: {0}")]
62    PasswordlessError(String),
63}
64
65pub type Result<T> = std::result::Result<T, AuthError>;