Build an `AuthContext` from an `AuthenticatedIdentity`. This is the centralized factory used by all auth flows (password, API key, certificate, trust). JWT flows can use `AuthContext::from_jwt()` directly when JWT claims are available for richer context.
(identity: &AuthenticatedIdentity)
| 13 | /// API key, certificate, trust). JWT flows can use `AuthContext::from_jwt()` |
| 14 | /// directly when JWT claims are available for richer context. |
| 15 | pub fn build_auth_context(identity: &AuthenticatedIdentity) -> AuthContext { |
| 16 | let mut ctx = AuthContext::from_identity(identity, generate_session_id()); |
| 17 | // Stamp the per-user default database so `$auth.database_id` is available |
| 18 | // for RLS predicates even before a `USE DATABASE` command. |
| 19 | ctx.database_id = identity.default_database; |
| 20 | ctx |
| 21 | } |
| 22 | |
| 23 | /// Enrich AuthContext with scope status data from the scope grant store. |
| 24 | /// |
no test coverage detected