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
//! `AuthUser` — the application identity contract (A9).
//!
//! The application owns identity schema. This trait is the seam between the
//! application's `User` type and the framework's auth extractors. The app
//! implements `AuthUser` for its user type, telling the framework:
//!
//! - What type the session stores as the user ID (`Id`).
//! - What session key the ID lives under (`SESSION_KEY`).
//! - How to get the ID from a user value (`id()`).
//!
//! The framework does NOT own the `User` model, the users table, or any
//! identity schema. It only owns the session-based auth DX.
//!
//! # Example
//!
//! ```ignore
//! use arcature::AuthUser;
//!
//! pub struct User { pub id: uuid::Uuid, pub email: String }
//!
//! impl AuthUser for User {
//! type Id = uuid::Uuid;
//! const SESSION_KEY: &'static str = "user_id";
//! fn id(&self) -> &uuid::Uuid { &self.id }
//! }
//! ```
use Serialize;
use DeserializeOwned;
/// The application identity contract.
///
/// Implemented by the application's user type. The framework uses this to
/// store/retrieve the user ID in the session and to type the auth
/// extractors (`Auth<U>`, `OptionalAuth<U>`, `AuthManager<U>`).
///
/// The application owns identity schema — this trait does NOT mandate a
/// fixed `User` table, role model, or permission system.