Expand description
Request auth for operator routes (kernel spec §3.2, §3.3): the session cookie, behind the browser rules. It replaces the walking skeleton’s development bearer token.
Constants§
- SESSION_
RECHECK - The longest a stream waits before it re-checks its session, however far off the expiry is. Tokio’s clock is monotonic and does not count time the machine is suspended, so a sleep until the expiry could wake long after it: a laptop asleep for a week would keep a stream past its session.
Functions§
- operator_
only - Put
router’s routes behind the browser rules (outermost) and the session cookie. Only routes added torouterbefore this call are covered: add every operator route first. - require_
operator - Axum middleware: the request must carry a live session cookie (401
unauthenticatedotherwise). The session goes into the request’s extensions asAuthenticated; when this request slid its expiry, the cookie is sent again so the browser’s copy lives as long. Not when the handler set a cookie of its own, nor once the session has ended (a request that revokes its own session): the browser keeps the lastSet-Cookie, and that must not be the dead token. - require_
step_ up - Axum middleware, inside
require_operator: the session’s last password or passkey check must be within the last five minutes (kernel spec §3.4), or the answer is 403step_up_requiredand the client asks again. - session_
ended - Resolves once
sessionhas ended: revoked, signed out, or expired. A stream a session holds open must not outlive it (3b decision 7), so long-lived responses end with this. It re-checks the session whenever the operator announces an ending, at its expiry (which may have slid since, through the session’s other requests), and at least everySESSION_RECHECK, against the wall clock. - step_
up_ required - 403
step_up_required: whatrequire_step_upanswers, for a handler that needs a fresh step-up for only some of what it does.