Skip to main content

alibi_core/
schema.rs

1//! Schema traits for binding Alibi to application-owned auth models.
2
3use crate::entity::{AuthAccount, AuthSession, AuthUser, AuthVerification};
4
5/// App-owned auth schema declaration.
6pub trait AuthSchema: Send + Sync + 'static {
7    /// Wire model projections for this application schema.
8    /// Add application fields here with their actual input/output policy; database
9    /// column names do not change canonical accessor-backed wire field names.
10    #[must_use]
11    fn openapi_models() -> Vec<crate::openapi::OpenApiModel> {
12        crate::openapi::annotations::core_models()
13    }
14
15    /// Preserve an authenticated cache snapshot only when the application user
16    /// type is itself a wire snapshot. Never reconstruct a database model from
17    /// cookie data. Typed physical guards reject cached-only authority otherwise.
18    fn user_from_cookie_cache(_user: crate::UserView) -> Option<Self::User> {
19        None
20    }
21
22    type User: AuthUser;
23    type Session: AuthSession;
24    type Account: AuthAccount;
25    type Verification: AuthVerification;
26}