| 1 | # Fresh identity assertions |
| 2 | |
| 3 | Status: design approved by Claude Fable 5 at 4b184e7 on 2026-09-08; implementation by Codex, for the user's accepted common app entry work. Code and deployed evidence require their own review. Prior Home exchange eaefda9 is enabled only on the existing paired preview; production is unchanged. Home design §10 and §14 require actual reauthentication before roster changes. Docs linking must prove fresh possession of both identities while retaining existing people.id and grants. |
| 4 | |
| 5 | Add one optional authorize parameter: max_age=300. Absence retains normal SSO, including an old but valid credential session and its unchanged original authentication time. Any other value, repeated parameter or unknown parameter is refused. Five minutes matches the intended sensitive-operation freshness window; arbitrary max-age parsing and zero-age semantics are deferred. |
| 6 | |
| 7 | Include MaxAge (0 or 300) and optional original Subject in the sealed ten-minute assertion intent. When max_age is requested and a credential session already exists, bind Subject to that session's opaque person ref. The issuer's session lookup is authoritative; no subject comes from a query or form. A new unauthenticated flow may bind to the person who subsequently signs in. At resume, require the normal complete credential session, validate intent, refuse a different bound subject, and check sessions.Fresh at the requested age before signing. A stale session redirects to the existing credential sign-in screen with the closed /authorize/resume continuation. Existing second-factor gates still run on both first-factor paths. |
| 8 | |
| 9 | For this bounded step-up, a valid fresh-intent cookie causes handleSigninBegin to select signin.MethodMagicLink. This uses the existing email confirmation and optional passkey/recovery factor. It avoids accepting a standing upstream Keymail inbox session as a new gesture. The decision must be server-side: the existing form action does not retain query flags, so a force=1 query alone is insufficient. Invalid/expired/duplicate intent cannot request or satisfy freshness. No new copy or inline scripts are needed. This extra mail ceremony applies only when the user reaches sign-in during an explicit fresh flow; ordinary SSO and ordinary Keymail sign-in are unchanged. |
| 10 | |
| 11 | Do not advance AuthTime while issuing an assertion. A freshly minted session whose original AuthTime is old remains stale. Time checks use sessions.Fresh plus an explicit verified-time <= now check. Source inspection of Rastrillo0.23 sessions.Fresh found that it only checks now.Sub(verified) <= maxAge, so it accepts future times by itself. The issuer must not credit them. On successful reauthentication, the new assertion carries the actual verified identity's AuthTime, falling back to the session At only when AuthTime is absent, as in the approved existing implementation. |
| 12 | |
| 13 | No consumer authorization is inferred from max_age. It is a request to the issuer, not a proof for the receiver. A sensitive consumer must independently reject an assertion or session whose actual AuthTime exceeds its five-minute window; an attacker removing max_age must not make account linking or roster writes accept stale authentication. Shared consumer query forwarding and its consumer-side freshness enforcement will be a separate implementation stage, followed by Docs account linking. Do not claim this issuer-only stage enables those actions. |
| 14 | |
| 15 | Extract one sealed-intent decoder used by resume and signin begin. Preserve all existing bounds, purpose, canonical base64, duplicate-cookie checks and fixed error responses. Its addition must not allow directory role to run credential handlers or render account-authored strings on credential origin. |
| 16 | |
| 17 | Acceptance: normal exchange retains old AuthTime; max_age with stale session produces no assertion and preserves return; fresh session succeeds without unnecessary mail; malformed/duplicate age is refused; original subject cannot switch during step-up; fresh-intent begin forces actual email despite a Keymail-classifying test stub; full email+optional recovery continuation yields an assertion with genuine fresh AuthTime; tampered/expired/duplicate intent does not count as step-up; local privacy, origin, script and whole unit/race gates remain green. Meaningful mutation must demonstrate freshness test fails when the freshness guard is removed. Independent Fable code review and actual CI precede an isolated preview deployment; live emailed authentication remains distinct from local mail-capture proof. |
| 18 | |
| 19 | |
| 20 | Implementation decisions after review: resolve the standing session explicitly with a.sessions.From at authorize because this router has no sessions.Middleware. A completed Keymail first factor plus recovery-code redemption qualifies as fresh within five minutes: recovery is a current credential and requires the gated first factor, while a half-session alone never qualifies. This is covered separately from stale-session forced mail. MaxAge=0 never forces mail. During rollback an old binary rejects a new nonzero-age sealed intent as an unknown field; the user must restart that in-flight exchange. No persistent data format changes. |
| 21 | |
| 22 | |
| 23 | ## Keymail step-up — 2026-10-24 |
| 24 | |
| 25 | Supersedes the forced-mail paragraph above for Keymail addresses whose server can demand a gesture; for every other address that paragraph still holds. |
| 26 | |
| 27 | keymaildev/signin v0.1.1 sends prompt=login when the federation server's /.well-known/keymail advertises "reauth": true (keymail serve answers prompt=login with 403 otherwise), and returns Identity.AuthTime, Keymail's report of the authenticator gesture, zero when none was reported. A forced login with a reported gesture time is a fresh gesture, which is what the forced mail existed to obtain, so a fresh intent no longer has to email a Keymail address on such a server. |
| 28 | |
| 29 | Begin. A fresh-intent begin classifies as usual. If the result is a Keymail continuation whose authorize URL carries exactly prompt=login, Home starts Keymail and sends no mail. If it is a Keymail continuation without prompt=login (a server that does not advertise reauth), Home discards it unsent and calls Begin again with the magic link forced: today's behaviour. A non-Keymail address gets the magic link, as before. The check is on the URL actually handed to the browser rather than on a separate classification, so it tests the fact that matters instead of predicting it, and classification still runs after the per-IP budget. The cost is a second address-budget token on the no-reauth path only. |
| 30 | |
| 31 | Callback. During a fresh flow (a valid sealed intent with MaxAge set) the Keymail return is credited only if AuthTime is non-zero, no later than now, and now - AuthTime <= MaxAge (300 s). Otherwise no session is minted and the browser goes to /signin?force=1, the existing Keymail fallback, with the intent and the /authorize/resume navigation cookie untouched. The form rendered at /signin?force=1 posts to /signin?force=1, because the browser submits the form's action and not the URL that rendered it. Before this, every Keymail fallback, ordinary ones included, classified again on submit and went straight back to Keymail; the existing tests posted to /signin?force=1 directly and hid it. The flag is convenience, not security: dropping it buys another Keymail round trip held to the same checks. The plain /signin form still posts to /signin. |
| 32 | |
| 33 | This check cannot be left to resume. Resume reads a zero AuthTime as the session's At, which is the callback's own clock, so a standing Keymail approval with no reported gesture would pass resume's freshness test. Resume's existing checks (sessions.Fresh, verified <= now, subject binding) still run afterwards, unchanged. |
| 34 | |
| 35 | No clock-skew allowance. A future AuthTime is refused outright. rastrillo's assertion validation refuses auth_time > iat, and the issued assertion must carry Keymail's AuthTime unaltered, so no future value can ever be issued. Allowing skew at the callback would only mint a session that resume bounces back to sign-in. Keymail's auth_time is whole seconds, truncated, and the gesture precedes the callback by at least one redirect, so synchronised clocks never trip it. A Keymail clock running ahead of Home's degrades to the email link, which is the safe direction. |
| 36 | |
| 37 | Unchanged: ordinary SSO and ordinary Keymail sign-in, including whatever prompt the library chooses there, with no gesture check on the return; subject binding (a different person's fresh Keymail gesture still gets 400 at resume); the passkey and recovery gates, which run in completeSignIn on both doors; and every sealed-intent bound. AuthTime is never advanced: the assertion carries Keymail's gesture time, tested to the second. |
| 38 | |
| 39 | Acceptance (keymail_fresh_test.go, against the existing keymail stub with "reauth" added): fresh intent plus a reauth server gives an authorize URL with exactly prompt=login and no mail; a gesture 90 s old yields an assertion whose auth_time equals Keymail's; zero, 301 s, one hour, +5 s and +1 h AuthTime give no session and fall back to email, and that email link completes the step-up through the form a browser would submit; a server without reauth gets forced mail; a non-Keymail address gets mail; ordinary Keymail with zero AuthTime still signs in; subject switching through Keymail is refused. Mutation: replacing the window with true fails all five fallback cases, as do removing the future bound or the age bound alone; dropping the prompt=login requirement fails the no-reauth tests; dropping the form's override fails the fresh fallback, the ordinary fallback and TestCredentialReturnKeymailAndFallback. Removing only the zero check survives, because a zero time is also more than 300 s old; the explicit check stays as documentation of the case Keymail defines. |
| 40 | |
| 41 | A Keymail session with no gesture time never satisfies a step-up. Resume refuses a session whose Method is exactly "keymail" and whose AuthTime is zero, even inside the window: sessions.Fresh would fall back to At, which is when Home minted the session, not anything the person did. The step-up then goes to sign-in, where the rules above apply (Keymail with prompt=login, or email). A completed second factor ("keymail+passkey", "keymail+recovery") sets AuthTime itself and is unaffected; magic-link sessions keep the At fallback, because the click is the gesture. Tested with a control (the same flow with a reported gesture mints) and mutation-checked: removing the guard fails the no-gesture case. |
| 42 | |
| 43 | Error re-renders (unparseable form, bad address, rate limit, internal error) draw the form through the same helper as the first GET, so a forced form keeps posting to /signin?force=1 after an error (TestForcedFormErrorsKeepTheOverride, failing first). |
| 44 | |
| 45 | Open, blocked on rastrillo (Astra review of #83 at 1f18405, P1): the guard above runs only when max_age is present. Without max_age, resume still substitutes session At for a Keymail session's missing AuthTime and signs it as auth_time, and a consumer that persisted its own five-minute requirement (handoff StartFresh) accepts it at age 0. The honest assertion for such a session carries no auth_time, which handoff's fresh check (age > freshAuthLifetime) and connect/linkstore's fresh() (at > 0) would both refuse. But rastrillo's assertion.validate, run by Sign and Verify alike, rejects AuthTime <= 0, so Home cannot issue one, and ordinary SSO for these sessions would break if it refused instead. Closing it needs rastrillo to let an assertion carry absent (unknown) auth_time, with every freshness consumer refusing that. Home then falls back to At only for the magic link. Not changed on this branch. |
| 46 | |
| 47 | Inherited by the directory's own fresh checks (2026-10-28): the operator confirm page (team-provisioning-amendment.md §4 step 2) and the Team page's writes (team-members.md §2, `teamFresh` in internal/home/team_page.go) check the directory session's auth_time, which came from whatever assertion minted it. A directory session minted by ordinary SSO (/auth/start, no max_age) from a Keymail session with no gesture inside the last 300 s carries auth_time = At and passes them, exactly as Docs linking does. Writes that arrive through /auth/fresh/start (max_age=300) are not affected: the issuer refuses that session there. It closes when rastrillo lets an assertion carry an absent auth_time. |
| 48 | |