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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Authentication error type.
//!
//! `AuthError` is `#[non_exhaustive]` — downstream matches must include a
//! wildcard arm so adding variants (e.g., rate-limit-exceeded, MFA-required)
//! in later phases is not a breaking change.
//!
//! Database/driver failures surface as `DjogiError::Db(DbError)` from the
//! Postgres substrate, not through `AuthError`. Provider-internal failures
//! that aren't driver errors wrap as `AuthError::Provider(...)`.
use Error;
/// Authentication and authorization failure modes.
///
/// Returned by [`DjogiAuth::authenticate`](super::DjogiAuth::authenticate) and
/// [`DjogiAuth::verify`](super::DjogiAuth::verify), and re-raised as
/// [`DjogiError::Auth`](crate::error::DjogiError::Auth) when those calls
/// propagate through `?` inside framework operations.
///
/// # Matching
///
/// The enum is `#[non_exhaustive]`. All downstream `match` arms must end with
/// a wildcard:
///
/// ```ignore
/// match err {
/// AuthError::InvalidToken => { /* ... */ }
/// AuthError::ExpiredSession => { /* ... */ }
/// _ => { /* forward-compatible catch-all */ }
/// }
/// ```
///
/// # Error hierarchy
///
/// `AuthError` is narrowly scoped to authentication and authorization logic.
/// It does NOT carry database/driver errors (those flow through
/// `DjogiError::Db`). Use `AuthError::Provider` to wrap any provider-internal
/// failure that is not covered by a more specific variant.