ferrohealth_session/lib.rs
1// SPDX-FileCopyrightText: Cadasto B.V.
2// SPDX-License-Identifier: BUSL-1.1
3
4//! The sign-in and the session of a FerroHEALTH operator console.
5//!
6//! An operator signs in at the deployment's OpenID Provider with the
7//! authorization code flow and PKCE, through the relying party of
8//! `ferrohealth-smart` (`ferrohealth_smart::oidc::RelyingParty`), which keeps
9//! no state of its own. This crate keeps the state between the redirect and
10//! the callback, and the session once the sign-in completes:
11//!
12//! - [`config`]: the `[oidc]` and `[session]` sections every console embeds,
13//! read with `deny_unknown_fields`, each secret through
14//! `ferrohealth-secret`'s `<key>` / `<key>_file` rule;
15//! - [`sessions::Sessions`]: the store, in process (`memory`, an opaque id in
16//! the cookie) or in one AES-256-GCM sealed cookie (`sealed`, for a console
17//! that runs as several instances with no shared store);
18//! - [`clock`]: the clock every lifetime is counted on, the wall clock by
19//! default, with `clock::ManualClock` (feature `test-clock`) for a
20//! console's tests;
21//! - [`lifetime`]: the idle and the absolute lifetime, both counted from
22//! times the session carries, the absolute one from the sign-in time, and
23//! what is left as FerroUI's session watch reads it;
24//! - [`sessions::Sessions::keep_fresh`]: the refresh of an access token before
25//! it expires;
26//! - `routes` (feature `axum`): `GET /login`, `GET /auth/callback`,
27//! `POST /logout` and `GET`/`POST /session`, and the middleware that hands
28//! every page what its request holds.
29//!
30//! No token, key, password, session id, `state`, `nonce` or verifier reaches a
31//! log line, a `Debug` rendering or an error message. No specification
32//! governs the session store, its lifetimes or the watch route: our own
33//! design, held to the OWASP Session Management Cheat Sheet (idle and
34//! absolute timeouts).
35
36pub mod clock;
37pub mod config;
38pub mod cookies;
39pub mod lifetime;
40pub mod paths;
41pub mod record;
42pub mod refresh;
43pub mod return_path;
44#[cfg(feature = "axum")]
45pub mod routes;
46pub mod sessions;
47
48mod store;