Prefer direct backend auth handoff
This commit is contained in:
parent
6795439ac7
commit
f8eec3558f
13 changed files with 515 additions and 47 deletions
|
|
@ -99,17 +99,22 @@ Preferred browser handoff:
|
|||
|
||||
1. Repixelizer opens Heimdall auth in a script-opened new tab/window
|
||||
2. Heimdall completes provider auth and upstream entitlement checks
|
||||
3. Heimdall callback posts a one-time completion code back to the opener
|
||||
4. the callback context tries to close itself
|
||||
5. Repixelizer backend redeems the completion code with Heimdall
|
||||
6. Repixelizer establishes local trusted auth state from the redeemed result
|
||||
3. Heimdall delivers the auth result directly to a Repixelizer backend callback
|
||||
endpoint keyed by a local auth attempt id
|
||||
4. Repixelizer backend establishes local trusted auth state from that direct
|
||||
delivery
|
||||
5. the callback context only needs to signal status, try to close itself, and
|
||||
offer a dead-simple return path
|
||||
6. the main Repixelizer page learns completion from its own backend by polling,
|
||||
SSE, or websocket
|
||||
|
||||
Important rule:
|
||||
|
||||
- Repixelizer should not rely on a raw access token arriving in the callback
|
||||
URL
|
||||
- the browser may see a one-time completion code in fallback paths, but the
|
||||
final trusted auth material should come from backend redemption
|
||||
- the browser should not be the primary carrier of the final auth result
|
||||
- the one-time completion-code redeem flow remains acceptable as a fallback,
|
||||
not the preferred same-host path
|
||||
|
||||
Repixelizer should still do locally:
|
||||
|
||||
|
|
|
|||
|
|
@ -349,19 +349,33 @@ The generic flow should be the same across hosted experiments:
|
|||
|
||||
The browser should never be the custodian of provider tokens.
|
||||
|
||||
Preferred browser handoff for hosted apps:
|
||||
Preferred same-host or Yggdrasil-reachable handoff for hosted apps:
|
||||
|
||||
1. the app keeps its main page open
|
||||
2. auth starts in a script-opened new browser context
|
||||
3. Heimdall callback completes the provider flow server-side
|
||||
4. Heimdall returns a short-lived one-time completion artifact
|
||||
5. the callback page `postMessage`s that artifact back to the opener and tries
|
||||
to close itself
|
||||
6. the host app backend redeems the artifact with Heimdall and establishes the
|
||||
app's local trusted auth state
|
||||
4. Heimdall delivers the auth result directly to the host app backend over an
|
||||
internal backend channel
|
||||
5. the host app backend establishes the app's local trusted auth state
|
||||
6. the callback page only needs to signal completion status, try to close
|
||||
itself, and offer a dead-simple return path
|
||||
|
||||
This avoids spraying long-lived app auth into callback URLs while still giving
|
||||
the user the familiar "log in over there, keep working over here" flow.
|
||||
Recommended browser role in that flow:
|
||||
|
||||
- the main app page tracks its own auth attempt locally
|
||||
- the main app page learns completion from its own backend by polling, SSE, or
|
||||
websocket
|
||||
- the browser should not be the primary carrier of the final auth result
|
||||
|
||||
Fallback flow for looser integrations:
|
||||
|
||||
- Heimdall can still mint a short-lived one-time completion artifact
|
||||
- the callback page can `postMessage` that artifact to the opener
|
||||
- the host app backend can redeem it with Heimdall
|
||||
- keep this as the portable escape hatch, not the preferred same-host path
|
||||
|
||||
This keeps the real auth handoff on the server side while still giving the
|
||||
user the familiar "log in over there, keep working over here" flow.
|
||||
|
||||
## App integration contract
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ What exists right now is:
|
|||
- persisted accounts, linked identities, sessions, grants, entitlement
|
||||
snapshots, and audit records
|
||||
- a real Discord provider callback slice for Repixelizer access
|
||||
- a direct backend callback handoff for same-host app integrations
|
||||
- a one-time browser completion handoff so auth callback pages can post back to
|
||||
the opener instead of leaking final app auth in URL fragments
|
||||
the opener instead of leaking final app auth in URL fragments, now retained
|
||||
as fallback rather than the preferred same-host path
|
||||
- file-backed signing-key loading/bootstrap for stable service identity
|
||||
- AES-256-GCM token sealing for managed provider credentials at rest
|
||||
- a local verifier helper that app backends can use against Heimdall JWKS
|
||||
|
|
@ -124,7 +126,7 @@ Next in this phase:
|
|||
### Phase 3: Repixelizer binding
|
||||
|
||||
- integrate Heimdall into the hosted demo
|
||||
- consume the one-time completion flow from the Repixelizer frontend/backend
|
||||
- consume the direct backend callback flow from the Repixelizer frontend/backend
|
||||
- gate `POST /api/jobs`
|
||||
- gate per-job read/cancel/event routes by local session ownership
|
||||
- consume the landed verifier seam so Repixelizer can trust Heimdall JWTs locally
|
||||
|
|
|
|||
|
|
@ -126,6 +126,11 @@ Request body:
|
|||
"appSlug": "repixelizer",
|
||||
"mode": "sign_in",
|
||||
"returnTo": "https://repixelizer.gamecult.org/app/",
|
||||
"handoff": {
|
||||
"kind": "backend_callback",
|
||||
"attemptId": "auth-attempt-123",
|
||||
"callbackUrl": "https://repixelizer.gamecult.org/api/auth/heimdall/callback"
|
||||
},
|
||||
"connection": {
|
||||
"kind": "creator",
|
||||
"targetId": "creator:alpha",
|
||||
|
|
@ -168,17 +173,41 @@ Current status:
|
|||
- for Discord, exchanges the authorization code, resolves the provider
|
||||
identity, persists the local account/link/session/audit records, evaluates
|
||||
Repixelizer entitlement facts, and issues a signed Heimdall access claim
|
||||
- for browser-style callers, renders a Heimdall-hosted completion page that
|
||||
posts a one-time completion code back to the opener and tries to close
|
||||
itself
|
||||
- if opener handoff fails, the completion page still offers a fallback return
|
||||
link carrying only the one-time completion code, not the access token
|
||||
- for non-browser callers, returns JSON with the issued claim/session data plus
|
||||
completion metadata
|
||||
- when `handoff.kind=backend_callback`, delivers the auth result directly to
|
||||
the app backend and renders a tiny browser status page that can close itself
|
||||
- when `handoff.kind=browser_completion` or handoff is omitted, keeps the older
|
||||
one-time completion-code flow as a fallback path
|
||||
- if opener handoff is used and fails, the completion page still offers a
|
||||
fallback return link carrying only the one-time completion code, not the
|
||||
access token
|
||||
- other configured providers still return "not implemented" at the runtime
|
||||
adapter layer until their callback paths are added
|
||||
|
||||
Success response for non-browser callers now includes:
|
||||
Success response for backend-callback handoff now includes:
|
||||
|
||||
```json
|
||||
{
|
||||
"delivery": {
|
||||
"kind": "backend_callback",
|
||||
"attemptId": "auth-attempt-123",
|
||||
"callbackUrl": "https://repixelizer.gamecult.org/api/auth/heimdall/callback",
|
||||
"status": "delivered"
|
||||
},
|
||||
"account": {
|
||||
"id": "acct_repixelizer_001",
|
||||
"displayName": "Meta"
|
||||
},
|
||||
"session": {
|
||||
"accountId": "acct_repixelizer_001",
|
||||
"sessionId": "uuid",
|
||||
"appSlug": "repixelizer",
|
||||
"accessRevision": 1,
|
||||
"expiresAt": "2026-04-26T13:00:00.000Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Success response for browser-completion fallback still includes:
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -190,6 +219,69 @@ Success response for non-browser callers now includes:
|
|||
}
|
||||
```
|
||||
|
||||
### Backend callback delivery payload
|
||||
|
||||
Purpose:
|
||||
|
||||
- push the final auth result directly into the app backend without asking the
|
||||
browser to courier it
|
||||
|
||||
Current payload shape on success:
|
||||
|
||||
```json
|
||||
{
|
||||
"source": "heimdall",
|
||||
"kind": "oauth_result",
|
||||
"handoffKind": "backend_callback",
|
||||
"attemptId": "auth-attempt-123",
|
||||
"status": "success",
|
||||
"provider": "discord",
|
||||
"appSlug": "repixelizer",
|
||||
"mode": "sign_in",
|
||||
"returnTo": "https://repixelizer.gamecult.org/app/",
|
||||
"account": {
|
||||
"id": "acct_repixelizer_001",
|
||||
"displayName": "Meta"
|
||||
},
|
||||
"session": {},
|
||||
"accessToken": "<signed-jwt>",
|
||||
"claimSet": {},
|
||||
"verification": {},
|
||||
"sharedCapabilities": ["app_access", "queue_submit"],
|
||||
"hybridCapabilities": [],
|
||||
"entitlements": {
|
||||
"facts": ["entitlement.app_access"],
|
||||
"snapshots": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Current payload shape on failure:
|
||||
|
||||
```json
|
||||
{
|
||||
"source": "heimdall",
|
||||
"kind": "oauth_result",
|
||||
"handoffKind": "backend_callback",
|
||||
"attemptId": "auth-attempt-123",
|
||||
"status": "error",
|
||||
"provider": "discord",
|
||||
"appSlug": "repixelizer",
|
||||
"mode": "sign_in",
|
||||
"returnTo": "https://repixelizer.gamecult.org/app/",
|
||||
"error": "oauth_callback_failed",
|
||||
"errorDescription": "..."
|
||||
}
|
||||
```
|
||||
|
||||
Important behavior:
|
||||
|
||||
- app backends should treat this as the preferred same-host or
|
||||
Yggdrasil-reachable integration path
|
||||
- app backends should still verify the included Heimdall `accessToken` locally
|
||||
- the browser only needs to learn attempt completion, not carry the final auth
|
||||
result
|
||||
|
||||
### `POST /v1/apps/{appSlug}/auth-completions/redeem`
|
||||
|
||||
Purpose:
|
||||
|
|
@ -197,6 +289,11 @@ Purpose:
|
|||
- redeem a short-lived one-time browser completion code
|
||||
- return the trusted Heimdall auth result to the app backend
|
||||
|
||||
Current role:
|
||||
|
||||
- fallback path for looser integrations, manual testing, or opener-based flows
|
||||
- not the preferred same-host consumer path anymore
|
||||
|
||||
Request body:
|
||||
|
||||
```json
|
||||
|
|
@ -367,6 +464,6 @@ The following are not landed yet:
|
|||
Consume the hardened slice in the first real app binding:
|
||||
|
||||
- the first Repixelizer consumer binding that trusts Heimdall claims locally
|
||||
- the first Repixelizer backend redeem path for completion codes
|
||||
- the first Repixelizer backend callback endpoint and attempt-status bridge
|
||||
- any missing app-local session bridge or verifier middleware sugar that makes
|
||||
that integration less feral
|
||||
|
|
|
|||
Loading…
Reference in a new issue