Expand description
AUTH-5: a reference in-memory backend and stores for the auth activation.
AUTH-5 — a reference, in-memory implementation of what a service
supplies the auth activation: MemoryRoles (RoleStore),
MemoryMemberships (MembershipStore) and MemoryAuthBackend
(AuthBackend, and a SessionValidator for the tokens it mints).
For tests, and as the shape a Plexus service starts from: a real service keeps the same answers in its own store (menger: its members table and sessions, AUTH-7) — reads from memory, writes through.
The backend’s flows:
- browser —
login {browser: {redirect}}keeps a state for the loopbackredirect(onlyhttp://127.0.0.1:…/http://localhost:…) and answers{login_url: "<login_url>?cli=1&state=…", state}. The service’s web sign-in, once the person is through, callsMemoryAuthBackend::complete_browser, which mints a one-time code (good for a minute) and gives the URL to send the browser back to.login {code: {code, state}}trades it for a session. - password — users added with
MemoryAuthBackend::with_user. - session — on a connection that is someone: a session for the same principal (and agent), its ceiling layered on the caller’s.
Tokens are mgs_<32 hex>; SessionValidator::validate takes the bare
token, Bearer <token>, or a Cookie header holding access_token=….
Structs§
- Memory
Auth Backend - An in-memory
AuthBackendandSessionValidator. See the module docs for its flows. - Memory
Memberships - Memberships as a list.
- Memory
Roles - An editable
RoleTable: the activations’ declared defaults, an admin’s edits replacing a role outright.
Constants§
- CODE_
TTL_ SECS - How long a browser flow’s code is good for.