1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use serde::{Deserialize, Serialize};
/// Errors that can occur during the authentication process.
#[derive(Debug, thiserror::Error)]
pub enum AuthError {
/// An error returned by the authentication provider
#[error("Provider error: {0}")]
Provider(String),
/// The provided credentials (email/password) are invalid
#[error("Invalid credentials")]
InvalidCredentials,
/// The authorization code is invalid or expired
#[error("Invalid code")]
InvalidCode,
/// A network error occurred during communication with the provider
#[error("Network error")]
Network,
/// An error occurred during session management
#[error("Session error: {0}")]
Session(String),
/// An error occurred during token processing
#[error("Token error: {0}")]
Token(String),
/// The CSRF state parameter does not match the expected value
#[error("CSRF state mismatch")]
CsrfMismatch,
/// An error occurred during OIDC discovery
#[error("Discovery error: {0}")]
Discovery(String),
/// A required component (e.g., SessionManager, TokenManager) is missing
#[error("Missing component: {0}")]
ComponentMissing(String),
/// Invalid input provided
#[error("Invalid input")]
InvalidInput,
/// Invalid or failed credentials verification
#[error("Credentials error: {0}")]
Credentials(String),
/// An internal or unexpected storage error occurred
#[error("Internal error: {0}")]
Internal(String),
}
/// Represents an error response from an OAuth2 provider.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OAuthErrorResponse {
/// The error code.
pub error: String,
/// A human-readable ASCII text description of the error.
pub error_description: Option<String>,
}