Docs: app-asserted step-up route, step_up_method claim, Bifrost profile grant, architecture note, evidence line
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
33a83c34c4
commit
2f93809a29
4 changed files with 101 additions and 1 deletions
|
|
@ -77,3 +77,15 @@ patron points locally.
|
|||
This route is a bridge from auth-owned Patreon evidence to Bifrost-owned
|
||||
governance meaning. Heimdall still does not own points, votes, tiers, ledger
|
||||
history, or payout policy.
|
||||
|
||||
## App-asserted step-up
|
||||
|
||||
Bifrost's profile carries `stepUpAssertion: { methods: ["bifrost-passkey",
|
||||
"bifrost-email-code"] }`, the only such grant. With its secret and a member's
|
||||
live Heimdall bearer, Bifrost calls `POST /v1/apps/bifrost/step-up` with
|
||||
`{method, nonce}` after it has checked the factor itself, and receives an access
|
||||
token for the same session whose `step_up_at` and `step_up_method` satisfy
|
||||
Heimdall's unlink check. Bifrost must send a fresh nonce per assertion, keep
|
||||
the returned token only for the action it is for, and never send a method it did
|
||||
not verify: Heimdall cannot tell. Contract, codes, limits and what it does not
|
||||
prove are in `docs/service-contract.md`.
|
||||
|
|
|
|||
|
|
@ -348,6 +348,18 @@ for the account that holds it. The store role therefore holds DELETE on
|
|||
`linked_identities`, checked at startup. The HTTP side (`/v1/me/identities`) is
|
||||
in `service-contract.md`; an unlink needs a step-up proof inside 600 seconds.
|
||||
|
||||
### Step-up proof has two sources
|
||||
|
||||
An access token's `step_up_at` is set in exactly two places: the `sign_in`
|
||||
step-up callback (Heimdall asked the provider to re-authenticate; label
|
||||
`provider:<name>`) and `assertStepUp`, the app-asserted route (the app says it
|
||||
checked a factor; label from the profile's `stepUpAssertion.methods`). Both
|
||||
feed the one reader, the unlink check, and a refresh sets neither. The
|
||||
asserted route trusts the calling app and is bounded by the app secret, a live
|
||||
bearer for that app, the method allowlist, a nonce claimed once per session
|
||||
through `claimOAuthStateUse` (phase `step_up_assert`, no new table or grant),
|
||||
and in-process fixed-window limits (`src/fixed-window.ts`).
|
||||
|
||||
### Three nested guards
|
||||
|
||||
1. **Single flight, per process.** `refreshesInFlight` is keyed by store, then
|
||||
|
|
|
|||
|
|
@ -599,7 +599,8 @@ body is empty or `null`.
|
|||
with the remaining list in the shape above.
|
||||
|
||||
`step_up_at` (epoch seconds) is set on the access claim only when the callback's
|
||||
signed state has `step_up` true and mode `sign_in`. A refresh never carries it:
|
||||
signed state has `step_up` true and mode `sign_in`, or by an app's `POST
|
||||
/v1/apps/{appSlug}/step-up` assertion (below). A refresh never carries it:
|
||||
tokens a refresh issues cannot unlink, so proof is renewed only by a new step-up
|
||||
sign-in. The unlink writes the audit event `identity_unlinked` (provider and
|
||||
identity id only). When the account then holds no identity of that provider, the
|
||||
|
|
@ -626,6 +627,78 @@ another account holds (`links/confirm` answers `409 identity_linked_elsewhere`,
|
|||
the callback `link_initiator_mismatch`). An unlinked identity belongs to no
|
||||
account and can be linked by any account through the normal link flow.
|
||||
|
||||
### `POST /v1/apps/{appSlug}/step-up`
|
||||
|
||||
An app asserts that a member just passed a factor the app itself checked (for
|
||||
Bifrost: a passkey assertion or an emailed code), and receives an access token
|
||||
that carries that proof. The unlink route's step-up check then passes unchanged.
|
||||
|
||||
Authentication: both, always.
|
||||
|
||||
- the app's secret in `x-heimdall-app-secret`, as for every app route; and
|
||||
- the member's live Heimdall access token for the same app as
|
||||
`Authorization: Bearer`.
|
||||
|
||||
Body (`additionalProperties` are dropped as on the sibling routes):
|
||||
|
||||
```json
|
||||
{ "method": "bifrost-passkey", "nonce": "16 to 128 characters, fresh per assertion" }
|
||||
```
|
||||
|
||||
Order of refusals, each a closed `error` code:
|
||||
|
||||
- `401 app_auth_required`: missing, wrong or another app's secret. Checked
|
||||
first; nothing is written.
|
||||
- `403 step_up_assertion_not_permitted`: the app's profile has no
|
||||
`stepUpAssertion` grant. Only `bifrost` has one; every other app is refused
|
||||
with its own secret.
|
||||
- `429 step_up_rate_limited` (`retryAfterSeconds`): the per-app budget (120 per
|
||||
60 s, spent by every attempt that passed the secret and the grant, including
|
||||
ones whose bearer then fails) or the per-account budget (10 per 600 s) is
|
||||
spent. In-process fixed windows: they reset when the process restarts and are
|
||||
not shared between instances.
|
||||
- `401 sign_in_required`: the bearer is missing, malformed, expired, signed by
|
||||
another key, a refresh token, or rests on a session that is not live (no row,
|
||||
wrong account, revoked or expired, revision moved). One answer for all of
|
||||
them; it does not say whether an account exists.
|
||||
- `403 bearer_app_mismatch`: a live bearer issued to another app. An app cannot
|
||||
assert for a token issued to another app.
|
||||
- `400 unknown_step_up_method`: `method` is not in the profile's closed set
|
||||
(`methods` in the answer lists it). Bifrost: `bifrost-passkey`,
|
||||
`bifrost-email-code`. Provider labels (`provider:*`) cannot be asserted.
|
||||
- `409 step_up_nonce_replayed`: that nonce was already spent for this session.
|
||||
The claim is the store's `oauth_state_uses` single-use primitive with phase
|
||||
`step_up_assert` and the key a SHA-256 of session id and nonce, so it holds
|
||||
across restarts and instances and is kept until the session's own expiry. A
|
||||
refused method or a rate-limited attempt does not spend the nonce.
|
||||
- `201`: `{"accessToken", "claimSet", "stepUp": {"at", "method", "validForSeconds"}}`,
|
||||
`Cache-Control: no-store`.
|
||||
|
||||
What the minted token is: a copy of the bearer's claims with a new `jti`,
|
||||
`iat` and `nbf`, `step_up_at` = now and `step_up_method` = the asserted method.
|
||||
It keeps the bearer's `exp`, same `sid` and account. Facts, capabilities and
|
||||
identities are the bearer's and are not recomputed, so the route adds proof and
|
||||
no capability. It mints no refresh token and writes no session row: it cannot
|
||||
extend a lifetime or a session. A later refresh carries neither claim. The proof
|
||||
is good for the usual 600 seconds (`STEP_UP_PROOF_TTL_SECONDS`) and only until
|
||||
the token's own `exp`.
|
||||
|
||||
Receipts: each assertion writes the audit event `step_up_asserted`, and each
|
||||
refusal after the secret verified writes `step_up_assertion_refused`, with the
|
||||
app, the account and session when the bearer resolved, `method` (null when it
|
||||
was not in the allowlist), `outcome`, `code` and `nonceDigest`. Never the
|
||||
secret, the bearer, the minted token or the nonce. A request without the secret
|
||||
writes nothing.
|
||||
|
||||
What this does not prove: Heimdall cannot see the passkey or the code. It trusts
|
||||
the calling app's word, exactly as it trusts `stepUpRequested` (asked, not
|
||||
verified). The word is bounded by the app secret, a live member bearer for that
|
||||
app, the profile's method allowlist, a single-use nonce, the proof window and
|
||||
the rate limits. A compromised Bifrost can assert proofs only for members whose
|
||||
live bearer it holds. `identity_unlinked` records the proof's `stepUpMethod`
|
||||
(`provider:<name>`, an app label, or null), and unlink does not yet require any
|
||||
particular method.
|
||||
|
||||
### `POST /v1/apps/{appSlug}/managed-credentials/resolve`
|
||||
|
||||
Purpose:
|
||||
|
|
@ -761,6 +834,8 @@ Current claim payload fields:
|
|||
- `typ`
|
||||
- `account_id`
|
||||
- `access_revision`
|
||||
- `step_up_at` optional: epoch seconds of the proof; set only by a `sign_in` step-up callback or `POST /v1/apps/{appSlug}/step-up`, never by a refresh
|
||||
- `step_up_method` optional: present exactly when `step_up_at` is; `provider:<name>` for a provider step-up sign-in, otherwise the method label the app asserted
|
||||
- `display_name` optional
|
||||
- `app.slug`
|
||||
- `app.profile_version`
|
||||
|
|
|
|||
|
|
@ -39,3 +39,4 @@
|
|||
{"ts": "2026-10-19T16:03:16+00:00", "type": "verification", "status": "accepted", "note": "Live d51fa6b (H1) verified by a real human sign-in: the operator's StreamPixels Twitch sign-in through Heimdall start/callback, 2026-10-19 ('Twitch auth worked fine'); a streampixels session was created 16:02:33Z, after the 15:51Z switch. Joystick consent round trip still open: joystick:follow_up:h1-joystick-consent-round-trip."}
|
||||
{"ts": "2026-11-12T23:10:15+00:00", "type": "design", "status": "accepted", "note": "Changelog 2026-11-12: sign_in start accepts stepUp (app-authenticated, sign_in only, off by default); signed state carries step_up; launch adds Twitch force_verify=true, YouTube prompt='login consent', Google prompt=login; any other provider is 400 step_up_not_supported; completion reports stepUpRequested. Not deployed. For joystick:follow_up:chat-s7055-7056 (StreamPixels link hardening, second factor via fresh sign-in)."}
|
||||
{"ts": "2026-11-13T19:10:00+00:00", "type": "design", "status": "accepted", "note": "Changelog 2026-11-13: GET /v1/me/identities lists an account's identities (no credentials, profile or email); POST /v1/me/identities/:id/unlink deletes one with a step-up proof (access claim step_up_at, 600 s, never carried by refresh), refuses the last identity (409), writes revocation receipts when the provider's last identity goes. upsertLinkedIdentity no longer moves an identity between accounts (IdentityHeldElsewhereError; links/confirm 409 identity_linked_elsewhere, callback link_initiator_mismatch). The store role needs DELETE on linked_identities (startup refuses without it): owner-role GRANT at deploy."}
|
||||
{"ts": "2026-11-13T20:01:42+00:00", "type": "design", "status": "accepted", "note": "Changelog 2026-11-13: POST /v1/apps/{app}/step-up (profile grant stepUpAssertion, bifrost only; methods bifrost-passkey, bifrost-email-code). App secret plus the member's live bearer for that app; mints a same-session access token with step_up_at now and new claim step_up_method (exp kept, no refresh, no session write); nonce single-use per session via oauth_state_uses phase step_up_assert (no schema change); in-process rate limits 10 per 600 s per account, 120 per 60 s per app; audit step_up_asserted and step_up_assertion_refused with a nonce digest. Provider step-up sign-ins now carry step_up_method provider:<name>; identity_unlinked records stepUpMethod. Heimdall cannot verify the factor: it trusts the calling app. Not deployed; no env, secret or migration. For heimdall-body:follow_up:chat-s7419-7419.", "branch": "heimdall/app-asserted-step-up"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue