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
//! # rainier-auth
//!
//! Authentication and authorization: [`Guard`]s that say *who* is making a
//! request, and a [`Gate`] that says *whether they may*.
//!
//! | | |
//! |---|---|
//! | [`Authenticatable`] | what the framework needs to know about a user model |
//! | [`UserProvider`] / [`RepositoryUserProvider`] | how users are found and their credentials verified |
//! | [`Hasher`] / [`Argon2Hasher`] | password hashing |
//! | [`Guard`] / [`TokenGuard`] / [`SessionGuard`] | how a request is tied to a user |
//! | [`AuthManager`] | named guards — `auth:api` |
//! | [`Authenticate`] | the middleware that enforces it |
//! | [`Gate`] | abilities and policies |
//!
//! ```ignore
//! let provider = Arc::new(RepositoryUserProvider::new(users, hasher));
//! let auth = Arc::new(
//! AuthManager::<User>::new("web")
//! .register(Arc::new(SessionGuard::new("web", provider.clone(), sessions)))
//! .register(Arc::new(TokenGuard::new("api", provider))),
//! );
//!
//! middleware.alias_factory("auth", move |args| {
//! Ok(Arc::new(Authenticate::from_args(auth.clone(), args)) as Arc<_>)
//! });
//!
//! router.get("/me", show).middleware(["auth:api"]);
//! ```
//!
//! ## One user type per manager
//!
//! [`AuthManager`] is generic over the user model rather than yielding
//! `dyn Authenticatable`. An application has one user model and wants it back
//! with its own type; erasing it would only force a downcast at every call
//! site. An application with genuinely distinct user kinds — customers and
//! staff, in different tables — registers one manager each, which is clearer
//! than one registry returning different shapes.
pub use Abilities;
pub use Challenges;
pub use ;
pub use ;
pub use ;
pub use ;
pub use BcryptVerifier;
pub use LegacyVerifier;
pub use ;
pub use ;
pub use ;
// Re-exported so implementors get the attribute macro without adding the
// dependency themselves.
pub use async_trait;