Skip to main content

laterite_auth/
lib.rs

1//! Laterite auth: backend user authentication and authorization.
2//!
3//! Provides the operator-facing security primitives the admin surface is
4//! built on: Argon2id password hashing, opaque server-side sessions, a
5//! role-based permission model over dotted permission strings, brute-force
6//! throttling, and an append-only access log. "Backend users" are the
7//! operators of the admin, kept distinct from any application's end users.
8//!
9//! This crate is HTTP-agnostic on purpose. It exposes an [`AuthService`] with
10//! plain async methods (`authenticate`, `verify_session`, `logout`) plus an
11//! [`AuthenticatedUser`] identity; the admin crate wraps these in Axum
12//! extractors, cookie handling, and the rendered login screen.
13
14pub mod audit_listener;
15pub mod error;
16pub mod migrations;
17pub mod password;
18pub mod permission;
19pub mod service;
20pub mod store;
21
22mod models;
23mod schema;
24
25pub use audit_listener::AuditListener;
26pub use error::AuthError;
27pub use migrations::{migrations, MODULE_ID};
28pub use models::{AccessEvent, BackendUser, BackendUserSummary};
29pub use permission::PermissionSet;
30pub use service::{
31    ActiveSession, AuditEntry, AuthConfig, AuthService, AuthenticatedUser, IssuedSession,
32    NewOperator, RecalledSession, RememberCredential, RequestContext, ResolvedSession,
33};
34pub use store::AuditRecord;
35
36/// The `laterite.auth` module: the framework's backend-user auth tables.
37pub struct AuthModule;
38
39impl laterite_core::Module for AuthModule {
40    fn id(&self) -> laterite_core::ModuleId {
41        laterite_core::ModuleId::new(MODULE_ID)
42    }
43    fn migrations(&self) -> laterite_core::MigrationSet {
44        migrations()
45    }
46    fn register(&self, registry: &mut laterite_core::Registry) {
47        registry.add(laterite_core::ModelListenerReg::all(std::sync::Arc::new(
48            audit_listener::AuditListener,
49        )));
50    }
51}