oficina / home Public

Oficina ID on the web: straight in, and every id.* page in the door card

Paul, 2026-11-20: with an existing id.oficina.works session, Continue with
Oficina ID goes straight into the app, with no Continue to the app page (as
native already does). GET /authorize/resume mints and renders the
self-submitting hand-off; id_continue.html is deleted. Linking (max_age=300)
and step-up still force a fresh sign-in. With no session you get the door.
POST /authorize/resume stays, behind CSRF. The minting GET refuses
prefetch/prerender and non-navigation fetches. The slice 1 spec records the
ruling and its accepted limits (a)-(d). Replace, replaced, signed out,
sign-out-all, the error page and the hand-off pages are drawn in the door
card with Oficina ID at the head.

Reviewed by Claude Fable: APPROVE at 0a63310 (all Low), fixes in 9dbc8e5,
final APPROVE; wording nit fixed in 94823a9. CI passed at 94823a9.
Discussion 142. Separate pre-existing issue tracked in 143.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from feat/web-straight-in into main.
Co-Authored-By: claude <claude~paul@keymail.dev>
claude agent, operated by paul@keymail.dev 4f3601625c8e901376b886d330cd0ddd8c1274ac parent a3a5ed1
19 files changed, +335 −60
  • AGENTS.md +4 −1
  • docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md +3 −1
  • docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md +12 −2
  • docs/superpowers/specs/2026-11-19-smart-door.md +3 −3
  • implementation/oficina-id-slice1-copy.md +2 −2
  • internal/home/calma.go +33 −8
  • internal/home/chrome.go +14 −1
  • internal/home/exchange.go +46 −8
  • internal/home/handoff_failure.go +3 −0
  • internal/home/handoff_reveal_test.go +10 −4
  • internal/home/id_browser_test.go +1 −1
  • internal/home/id_exchange_test.go +173 −10
  • internal/home/render.go +1 −1
  • internal/home/shared_chrome_test.go +8 −2
  • internal/home/static/handoff-noscript.css +1 −1
  • internal/home/static/handoff.css +4 −2
  • internal/home/templates/id_continue.html +0 −7
  • internal/home/templates/id_error.html +14 −0
  • internal/home/templates/layout.html +3 −6

CI passed — run details

CI log
amadan: .amadan/timeout: this job's budget is 20m0s (this runner allows up to 30m0s)
=== vet ===
CGO_ENABLED=0 go vet ./...
CGO_ENABLED=0 go vet -tags browser ./internal/home/
cd handoff && CGO_ENABLED=0 go vet ./...
cd roster && CGO_ENABLED=0 go vet ./...
cd dashboard && CGO_ENABLED=0 go vet ./...
cd connect && CGO_ENABLED=0 go vet ./...
cd teammode && CGO_ENABLED=0 go vet ./...
=== fmt ===
=== build ===
CGO_ENABLED=0 go build ./...
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./cmd/home ./cmd/oficina ./internal/operatorlaunch
cd handoff && CGO_ENABLED=0 go build ./...
cd roster && CGO_ENABLED=0 go build ./...
cd dashboard && CGO_ENABLED=0 go build ./...
cd connect && CGO_ENABLED=0 go build ./...
cd teammode && CGO_ENABLED=0 go build ./...
=== go-test ===
CGO_ENABLED=0 go test -count=1 ./...
?   	amadan.net/oficina/home/cmd/home	[no test files]
ok  	amadan.net/oficina/home/cmd/home-placeholder	0.692s
?   	amadan.net/oficina/home/cmd/oficina	[no test files]
ok  	amadan.net/oficina/home/internal/guardstest	0.146s
ok  	amadan.net/oficina/home/internal/home	55.140s
ok  	amadan.net/oficina/home/internal/home/directorydata	1.362s
ok  	amadan.net/oficina/home/internal/home/logtest	0.004s
ok  	amadan.net/oficina/home/internal/home/seal	0.002s
ok  	amadan.net/oficina/home/internal/home/sealtest	0.003s
ok  	amadan.net/oficina/home/internal/home/wisp	0.044s
ok  	amadan.net/oficina/home/internal/operator	6.332s
ok  	amadan.net/oficina/home/internal/operatorlaunch	4.102s
ok  	amadan.net/oficina/home/internal/provisioner	48.478s
cd handoff && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/handoff	0.651s
ok  	amadan.net/oficina/home/handoff/seal	0.002s
cd roster && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/roster	5.117s
cd dashboard && CGO_ENABLED=0 go test ./...
ok  	amadan.net/oficina/home/dashboard	(cached)
cd connect && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/connect	1.392s
ok  	amadan.net/oficina/home/connect/linkstore	0.455s
cd teammode && CGO_ENABLED=0 go test -count=1 ./...
ok  	amadan.net/oficina/home/teammode	0.095s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
=== race ===
go test -race -count=1 ./internal/home/ ./internal/operator/ ./internal/operatorlaunch/ ./internal/home/directorydata/
ok  	amadan.net/oficina/home/internal/home	330.071s
ok  	amadan.net/oficina/home/internal/operator	82.050s
ok  	amadan.net/oficina/home/internal/operatorlaunch	22.379s
ok  	amadan.net/oficina/home/internal/home/directorydata	23.232s
ok  	amadan.net/oficina/home/internal/provisioner	394.407s
cd handoff && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/handoff	12.773s
ok  	amadan.net/oficina/home/handoff/seal	1.014s
cd roster && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/roster	6.946s
cd dashboard && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/dashboard	1.062s
cd connect && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/connect	6.115s
ok  	amadan.net/oficina/home/connect/linkstore	6.272s
cd teammode && CGO_ENABLED=1 go test -race -count=1 ./...
ok  	amadan.net/oficina/home/teammode	1.905s
?   	amadan.net/oficina/home/teammode/teammodetest	[no test files]
diff --git a/AGENTS.md b/AGENTS.md
index a64eb80..73331fb 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -465,7 +465,10 @@ quietly ignored).
which keeps its own design. On the directory a signed-in person has one
account menu (Passkeys and Recovery codes on id.*, Appearance, Help →
Open source, the one Sign out); id.*'s pages are the door, with a
- brand-only bar. Unknown routes get estilo's error page for a browser
+ brand-only bar: every one sits in the door's card, branded Oficina ID
+ as its sign-in door is, its error page and hops included (Paul,
+ 2026-11-20; `doorPages`, `hopPages`, `id_error.html`), Open source's
+ long list being the one exception. Unknown routes get estilo's error page for a browser
(`Accept: text/html`) and plain text otherwise. Calma's sky goes only on
the door, the team home's header and the front page's hero. Home does
not load estilo's `chrome.js`: its menus work without it, and the
diff --git a/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md b/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
index 8e07292..3603dae 100644
--- a/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
+++ b/docs/superpowers/plans/2026-11-13-oficina-id-slice1-home.md
@@ -6,7 +6,9 @@ no deployment or merge. Equipo and changes to its connect adapter are part B.
## Tasks
1. [x] Require a new authentication gesture for `max_age=300`; add a protected,
- fixed-label Continue page for existing sessions. Files: `exchange.go`,
+ fixed-label Continue page for existing sessions. (The Continue page is
+ superseded 2026-11-20 by Paul's straight-in ruling: an existing session
+ now mints on the GET; slice 1 spec, Assertion and browser exchange.) Files: `exchange.go`,
`signin.go`, `app.go`, templates, assertion tests. Preserve the closed
consumer manifest and 120-second P-256 assertions.
2. [x] Add browser-bound, five-minute, single-use direct passkey sign-in and
diff --git a/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md b/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
index 03d5063..1987675 100644
--- a/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
+++ b/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
@@ -1,6 +1,6 @@
# 🤖 Oficina ID: slice 1
-Status: revised design, 2026-11-13, applying Paul's rulings and Fable's READY AFTER FIXES review as supplied by Paul. Independently reviewed after these fixes by GPT-6 Astra (`gpt-6-astra`): acceptable as a spec, no blocking findings. Author: Codex. No implementation, deployment or merge approval.
+Status: revised design, 2026-11-13, applying Paul's rulings and Fable's READY AFTER FIXES review as supplied by Paul. Independently reviewed after these fixes by GPT-6 Astra (`gpt-6-astra`): acceptable as a spec, no blocking findings. Author: Codex. Slice 1 was implemented and merged on Home `main` under Paul's approval of 2026-11-13. Amended 2026-11-20 by Paul's web straight-in ruling (Assertion and browser exchange, step 2), built on Home `feat/web-straight-in`, reviewed by Claude Fable (APPROVE, low findings applied); that branch is not yet merged or deployed.
## Decision and boundary
@@ -55,10 +55,20 @@ Reuse `rastrillo/assertion` v1: P-256, context `rastrillo/assertion/v1`, `base64
No email, role, grants, document list, encryption keys or authentication-strength claim. Existing roster hints remain separately reviewed, invalidation-only exceptions under Home §5.4.
1. The app stores a short-lived transaction with independent browser secret, nonce, purpose and validated local return path/query. Set a `__Host-` pending cookie. Redirect to `/authorize` with exactly one `consumer`, one `nonce`, and optionally one `max_age=300`. No other parameters, duplicates or other `max_age` values; this matches `handleAuthorize`'s closed parser. Linking always includes `max_age=300`. Local accounts, documents and privileges stay app-side.
-2. Home validates the consumer and authenticates. For an ordinary existing session, **show a fixed-label Continue page before minting**; do not issue silently. Use operator-controlled service labels, no account-authored text. Linking always requires new authentication, regardless of session age. After Continue/authentication, deliver by form POST with optional static auto-submit and a manual button. Never put assertions in URLs or logs; use `no-store` and `strict-origin-when-cross-origin`, since `no-referrer` can null the POST Origin.
+2. Home validates the consumer and authenticates. For an ordinary existing session, **mint straight away, with no Continue page** (amended 2026-11-20 by Paul's straight-in ruling, below; it used to show a fixed-label Continue page before minting). Use operator-controlled service labels, no account-authored text. Linking always requires new authentication, regardless of session age. After authentication, deliver by form POST with optional static auto-submit and a manual button. Never put assertions in URLs or logs; use `no-store` and `strict-origin-when-cross-origin`, since `no-referrer` can null the POST Origin.
3. Accept only a bounded form POST with exact issuer `Origin`. Verify signature, issuer, audience, types and times. Before storing a receipt, require its signed nonce to match a live pending transaction; check and insert atomically. Reserve `(iss,jti)` uniquely so repeated callbacks refuse. Unknown nonces and storage failures store nothing.
4. Store a sealed, expiring inbox receipt, then redirect to `/auth/finish`. Its top-level GET receives the original SameSite=Lax cookie. Recheck the browser secret, nonce, expiry and account binding. Consume the pending/inbox proof, record replay use, resolve the current mapping/admission and mint the session atomically. Preserve the clock watermark and replay retention through expiry plus thirty seconds across restarts. Never mint at the cross-site POST.
+**Straight in on the web (Paul's ruling, 2026-11-20).** Someone already signed in to id.* who taps "Continue with Oficina ID" in an app goes straight into the app, as the native apps already do (Paul's 11-19 "one ID = straight in", native spec §9). `GET /authorize/resume` mints and renders the form-POST delivery itself (auto-submit, with the Continue button for scripts off); the "Continue to the app" page is gone. Safety (Fable's review of connect, 2026-11-20): a third-party-triggered GET to the app's `/signin/oficina` or `/auth/start`, or to `/authorize`, binds the exchange to the victim's own pending cookie, the victim's own id.* session and an assertion posted from the victim's own browser, so no attacker identity can be planted. Only a top-level navigation mints: the GET refuses `Sec-Purpose`/`Purpose` prefetch or prerender, and when `Sec-Fetch-*` headers are present requires `Sec-Fetch-Mode: navigate` and `Sec-Fetch-Dest: document`. The minting GET is deliberately outside the CSRF check (it is a GET); `POST /authorize/resume`, kept for a Continue page open in a tab, stays behind it.
+
+**Accepted limits of Paul's ruling** (Fable's review of `feat/web-straight-in`, 2026-11-20). "The worst case is signing the victim in to their own account" is too narrow; these are accepted:
+- (a) any site can sign a visitor who has an id.* session in to any registered consumer with no click; whether that first visit creates app-side state depends on each app's `Complete`;
+- (b) any registered consumer origin, or script running on one, learns a visitor's Oficina subject with no id.* interaction;
+- (c) a junk-nonce `/authorize` overwrites the victim's in-flight intent cookie (and, through the app's callback, its inbox cookie; the app's start replaces its pending cookie), breaking a sign-in in progress;
+- (d) whether a browser has an id.* session (it leaves id.* at once, or stays on the door) is visible to registered consumers by design; no cross-site read of it was found.
+
+Unchanged: `max_age=300` (linking, and every step-up) still sends a standing session to the door for a new authentication gesture before anything is minted (Linking and unlinking, below); without an id.* session the request still lands on the sign-in door; the assertion still never appears in a URL or a log.
+
The final transaction boundary is a required adapter change: today's `handoff.Finish` commits before `Complete`. Do not leave a consumed proof in memory that can mint after unlink/relink. Reject swapped browsers, purposes or accounts; an assertion cannot silently replace another signed-in account. Only the callback bypasses ordinary cross-origin request-forgery checks. Bound pending/inbox rows and prune them; keep local return queries app-side.
## Linking and unlinking
diff --git a/docs/superpowers/specs/2026-11-19-smart-door.md b/docs/superpowers/specs/2026-11-19-smart-door.md
index 6a97345..585a265 100644
--- a/docs/superpowers/specs/2026-11-19-smart-door.md
+++ b/docs/superpowers/specs/2026-11-19-smart-door.md
@@ -191,9 +191,9 @@ request can do is forget.
**The returning path for an Oficina ID user** on an app: tap Continue with
Oficina ID; id.oficina.works opens on Sign in with your passkey; one touch;
-back in the app. If an id.* session is still alive, it's the existing
-Continue page instead of the passkey. Skipping that Continue stays a separate
-question (native spec, question 3).
+back in the app. If an id.* session is still alive, there is no door at all:
+straight back in the app (Paul's ruling 2026-11-20, which retired the
+Continue page; slice 1 spec, Assertion and browser exchange, step 2).
## The cookie
diff --git a/implementation/oficina-id-slice1-copy.md b/implementation/oficina-id-slice1-copy.md
index b1203b7..9c2f422 100644
--- a/implementation/oficina-id-slice1-copy.md
+++ b/implementation/oficina-id-slice1-copy.md
@@ -19,8 +19,8 @@ Reviewed by GPT-6 Astra. Fixed labels only; no account-authored text.
- A replacement passkey was added to your Oficina account. All previous passkeys were removed, all Oficina ID sessions were signed out, and all recovery codes were invalidated. You may remain signed in to the directory and other apps. Sign in with your new passkey to create new recovery codes.
- Your passkeys were replaced, but we could not send the confirmation email.
- Send email again
-- Continue to the app · Oficina
-- Continue to the app
+- ~~Continue to the app · Oficina~~ (retired 2026-11-20: straight in, Paul's ruling; the page is gone)
+- ~~Continue to the app~~ (retired 2026-11-20, as above)
- Continue
- Signed out · Oficina
- You are signed out
diff --git a/internal/home/calma.go b/internal/home/calma.go
index 7d77449..1f66a96 100644
--- a/internal/home/calma.go
+++ b/internal/home/calma.go
@@ -45,24 +45,38 @@ var homeFuncs = map[string]any{
"forgetLabel": func() string { return chrome.English.Forget },
"linkLifetime": func() int { return int(chrome.LinkLifetime.Minutes()) },
// doorView is estilo-door-open's data: the suite's sky behind one
- // card, the Oficina mark and name at its head.
- "doorView": func() doorView {
- return doorView{Sky: sky.For(sky.SuiteSeed), Icon: versioned("/static/brand/icon.svg"), App: suiteName}
+ // card, the Oficina mark and the page's brand at its head (page.Brand:
+ // "Oficina ID" on id.*, as on its sign-in door; "Oficina" on the
+ // directory).
+ "doorView": func(brand any) doorView {
+ return doorView{Sky: sky.For(sky.SuiteSeed), Icon: versioned("/static/brand/icon.svg"), App: brandOr(brand)}
},
- // hopSky is the sky a hop page keeps: the inline placeholder alone, a
- // data: URI, so the moment between two skies is not a blank page and
- // still fetches nothing it will not show (r3 C2).
- "hopSky": func() sky.View {
+ // hopDoor is the door a hop page keeps: the same card and brand, on
+ // the sky's inline placeholder alone, a data: URI, so the moment
+ // between two skies is not a blank page and still fetches nothing it
+ // will not show (r3 C2). The card itself stays hidden unless the hop
+ // stalls (handoff.css).
+ "hopDoor": func(brand any) doorView {
var v sky.View
for _, l := range sky.For(sky.SuiteSeed).Layers {
if l.Inline != "" {
v.Layers = append(v.Layers, l)
}
}
- return v
+ return doorView{Sky: v, Icon: versioned("/static/brand/icon.svg"), App: brandOr(brand)}
},
}
+// brandOr is the brand a door card names: the page's, else the suite's.
+// It takes any because a page drawn with bare data in a test has no
+// Brand at all.
+func brandOr(brand any) string {
+ if s, ok := brand.(string); ok && s != "" {
+ return s
+ }
+ return suiteName
+}
+
// doorView is estilo-door-open's data (chrome/templates/signin.html).
type doorView struct {
Sky sky.View
@@ -81,7 +95,18 @@ const suiteName = "Oficina"
// error pages are plain pages under the bar.
// Not assertion.html or docs_continue.html: they are hops (hopPages). Not
// door.html either: estilo-signin-screen draws the door itself.
+//
+// Every page id.* draws is the door or a hop (Paul, 2026-11-20: every id.*
+// page in the door's card), the error page included: on id.* it is
+// id_error.html, the same words in the card (chrome.go, errorPage). The
+// one exception is Open source (credits.html), a long list that is the
+// same page on both origins.
var doorPages = map[string]bool{
+ "id_error.html": true,
+ "id_replace.html": true,
+ "id_replaced.html": true,
+ "id_signed_out.html": true,
+ "id_signout_all.html": true,
"id_forget.html": true,
"signin_confirm.html": true,
"signin_failed.html": true,
diff --git a/internal/home/chrome.go b/internal/home/chrome.go
index 08de0fa..928e1de 100644
--- a/internal/home/chrome.go
+++ b/internal/home/chrome.go
@@ -39,6 +39,10 @@ type page struct {
// Theme is <html data-theme>: "light", "dark", or empty to follow the
// system (the Appearance preference, per host).
Theme string
+ // Brand is the name at the head of a door or hop card: "Oficina ID"
+ // on id.*, as its sign-in door says (doorName); empty, which draws
+ // "Oficina", on the directory.
+ Brand string
}
// The account menu's and the bar's words. Home speaks English only today;
@@ -60,6 +64,9 @@ func (a *App) onCredential(r *http.Request) bool {
// text, so the page still holds exactly one link, the way on.
func (a *App) pageFor(r *http.Request, status int, data any, door, hop bool) page {
p := page{Data: data}
+ if a.onCredential(r) {
+ p.Brand = doorName
+ }
brand := chrome.App{Name: suiteName, Slug: "oficina", Home: "/", Icon: versioned("/static/brand/icon.svg")}
if hop {
brand.Home = ""
@@ -205,7 +212,13 @@ func (a *App) errorPage(w http.ResponseWriter, r *http.Request, status int) {
data.Back = &chrome.Link{Href: r.URL.RequestURI(), Label: "Try again"}
}
}
- a.renderPage(w, r, status, "error.html", errorView{chrome.Title(c.page, suiteName), data})
+ // On id.* the same words sit in the door's card (Paul, 2026-11-20:
+ // every id.* page in the door's card); elsewhere, estilo's error page.
+ name := "error.html"
+ if a.onCredential(r) {
+ name = "id_error.html"
+ }
+ a.renderPage(w, r, status, name, errorView{chrome.Title(c.page, suiteName), data})
}
// errorView is error.html's data: the tab title and estilo-error's.
diff --git a/internal/home/exchange.go b/internal/home/exchange.go
index e9023bd..9f961ff 100644
--- a/internal/home/exchange.go
+++ b/internal/home/exchange.go
@@ -76,6 +76,10 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
a.failAssertion(w, r, assertionQuery)
return
}
+ if r.Method == http.MethodGet && !mintingNavigation(r) {
+ a.failAssertion(w, r, assertionNotNavigation)
+ return
+ }
now := time.Now()
intent, ok := a.readAssertionIntent(r, now)
if !ok {
@@ -121,14 +125,25 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
a.failAssertion(w, r, assertionConsumer)
return
}
- if r.Method == http.MethodGet {
- if tx.Commit() != nil {
- a.failAssertion(w, r, assertionSession)
- return
- }
- a.render(w, r, http.StatusOK, "id_continue.html", nil)
- return
- }
+ // Straight in (Paul, 2026-11-20; slice 1 spec, "Assertion and browser
+ // exchange" step 2): someone already signed in to id.* goes straight
+ // to the app. The GET mints, with no "Continue to the app" page, and
+ // is deliberately outside csrf.Protect's reach (a GET); only a
+ // top-level navigation mints (mintingNavigation). Everything it binds
+ // to is the victim's own: the intent cookie this browser was given by
+ // /authorize, this browser's id.* session, and the delivery, a form
+ // POST from this browser to the consumer, whose finish matches the
+ // nonce against that browser's own pending cookie, so no attacker
+ // identity can be planted. The accepted limits of Paul's ruling are
+ // wider than "signs the victim in to their own account" and are listed
+ // in the slice 1 spec (Assertion and browser exchange): any site can
+ // sign a victim in to any registered app with no click; any registered
+ // app learns a visitor's subject with no id.* interaction; a junk
+ // /authorize overwrites an in-flight intent; and session presence is
+ // visible to registered apps. A step-up or a link (max_age) never
+ // reaches here on a standing session: the check above sent it to the
+ // door for a new gesture. The POST, behind csrf.Protect, is kept for a
+ // Continue page still open in a tab.
id, err := assertion.RandomID()
if err != nil {
a.failAssertion(w, r, assertionRandom)
@@ -159,3 +174,26 @@ func (a *App) handleAssertion(w http.ResponseWriter, r *http.Request) {
func keymailWithoutGesture(session sessions.Session) bool {
return session.Method == string(signin.MethodKeymail) && session.AuthTime.IsZero()
}
+
+// mintingNavigation reports whether a GET of /authorize/resume may mint:
+// a top-level navigation, never a prefetch or prerender, and never a
+// fetch, an image or a frame (defence in depth for straight in, Fable's
+// review of 2026-11-20). A browser that sends no Sec-Fetch headers is
+// judged on Sec-Purpose and Purpose alone; one that sends any must say
+// navigate and document.
+func mintingNavigation(r *http.Request) bool {
+ for _, name := range []string{"Sec-Purpose", "Purpose", "X-Purpose", "X-Moz"} {
+ for _, v := range r.Header.Values(name) {
+ v = strings.ToLower(v)
+ if strings.Contains(v, "prefetch") || strings.Contains(v, "prerender") || strings.Contains(v, "preview") {
+ return false
+ }
+ }
+ }
+ _, mode := r.Header["Sec-Fetch-Mode"]
+ _, dest := r.Header["Sec-Fetch-Dest"]
+ if mode || dest {
+ return r.Header.Get("Sec-Fetch-Mode") == "navigate" && r.Header.Get("Sec-Fetch-Dest") == "document"
+ }
+ return true
+}
diff --git a/internal/home/handoff_failure.go b/internal/home/handoff_failure.go
index 85a4fc6..40a75ed 100644
--- a/internal/home/handoff_failure.go
+++ b/internal/home/handoff_failure.go
@@ -20,6 +20,7 @@ const (
assertionSubject
assertionRandom
assertionSign
+ assertionNotNavigation
)
// Only this fixed vocabulary reaches logs; no request or error is accepted.
@@ -48,6 +49,8 @@ func (a *App) failAssertion(w http.ResponseWriter, r *http.Request, code handoff
reason = "random_id"
case assertionSign:
reason = "signing"
+ case assertionNotNavigation:
+ reason = "not_navigation"
}
a.logger.Warn("home handoff failed", "stage", stage, "reason", reason)
a.renderHandoffFailure(w, r, http.StatusBadRequest)
diff --git a/internal/home/handoff_reveal_test.go b/internal/home/handoff_reveal_test.go
index 8872b52..4840566 100644
--- a/internal/home/handoff_reveal_test.go
+++ b/internal/home/handoff_reveal_test.go
@@ -44,10 +44,10 @@ func TestHandoffInterstitialStaysHiddenWhileItAutoSubmits(t *testing.T) {
}
for path, wants := range map[string][]string{
"/static/handoff.css": {
- "[estilo-handoff]{animation:estilo-reveal0s1.5sboth;}",
+ "[estilo-door]>[estilo-signin]{animation:estilo-reveal0s1.5sboth;}",
"@keyframesestilo-reveal{from{visibility:hidden}to{visibility:visible}}",
},
- "/static/handoff-noscript.css": {"[estilo-handoff]{animation:none;}"},
+ "/static/handoff-noscript.css": {"[estilo-door]>[estilo-signin]{animation:none;}"},
} {
for _, host := range []string{credentialHost, directoryHost} {
req := httptest.NewRequest(http.MethodGet, path, nil)
@@ -70,10 +70,16 @@ func TestHandoffInterstitialStaysHiddenWhileItAutoSubmits(t *testing.T) {
// bar and the sky's placeholder sit outside it, so the hop is never a
// blank page (r3 C2).
main := body[strings.Index(body, "<main"):strings.Index(body, "</main>")]
- start := strings.Index(main, "<section estilo-signin estilo-handoff>")
- if start < 0 || !strings.Contains(main[:start], `estilo-sky-layer="placeholder"`) {
+ // The card is the door's, with the brand at its head (Paul,
+ // 2026-11-20: every id.* page in the door's card); handoff.css hides
+ // it, and only the sky's inline placeholder is behind it.
+ start := strings.Index(main, "<section estilo-signin>")
+ if start < 0 || !strings.Contains(main[:start], `<div estilo-door estilo-sky-host>`) || !strings.Contains(main[:start], `estilo-sky-layer="placeholder"`) || strings.Count(main[:start], "estilo-sky-layer=") != strings.Count(main[:start], `estilo-sky-layer="placeholder"`) {
t.Fatalf("content not wrapped in the hidden card on the sky:\n%s", main)
}
+ if !strings.Contains(main[start:], `<span>Oficina</span></p>`) || !strings.Contains(main[start:], `<p estilo-brand><img estilo-brand-icon="listing"`) {
+ t.Fatalf("the hidden card has no brand at its head:\n%s", main)
+ }
inner := main[start:strings.Index(main, "</section>")]
if !strings.Contains(inner, `data-assertion-handoff`) || !strings.Contains(inner, `<button type="submit" rst-btn="primary">Continue</button>`) {
t.Fatalf("hand-off form changed:\n%s", inner)
diff --git a/internal/home/id_browser_test.go b/internal/home/id_browser_test.go
index d1692a3..0dd980e 100644
--- a/internal/home/id_browser_test.go
+++ b/internal/home/id_browser_test.go
@@ -171,7 +171,7 @@ func TestIDBrowserScriptlessCrossSiteReturn(t *testing.T) {
p, ctx, _ := idBrowser(t)
idBrowserRun(t, ctx, cdpStep(emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: true}), chromedp.Navigate(p.directory.origins.Directory+"/auth/start"), chromedp.WaitVisible("#rst-signin-email"), chromedp.SendKeys("#rst-signin-email", sealtest.CanaryAddress), chromedp.Click(`form[action="/signin"] button`), chromedp.WaitVisible(`form[action="/signin/forget"] button`))
token := capturedLink(t, p.credential)
- idBrowserRun(t, ctx, chromedp.Navigate(browserIssuer+linkPath+"?token="+url.QueryEscape(token)), chromedp.WaitVisible(`form[action="/signin/verify"] button`), chromedp.Click(`form[action="/signin/verify"] button`), chromedp.WaitVisible(`form[action="/authorize/resume"] button`), chromedp.Click(`form[action="/authorize/resume"] button`), chromedp.WaitVisible(`form[data-assertion-handoff] button`), chromedp.Click(`form[data-assertion-handoff] button`), chromedp.WaitVisible(`[estilo-account]`))
+ idBrowserRun(t, ctx, chromedp.Navigate(browserIssuer+linkPath+"?token="+url.QueryEscape(token)), chromedp.WaitVisible(`form[action="/signin/verify"] button`), chromedp.Click(`form[action="/signin/verify"] button`), chromedp.WaitVisible(`form[data-assertion-handoff] button`), chromedp.Click(`form[data-assertion-handoff] button`), chromedp.WaitVisible(`[estilo-account]`))
var location string
idBrowserRun(t, ctx, harness.Into(&location, chromedp.Location()))
if !strings.HasPrefix(location, p.directory.origins.Directory+"/") {
diff --git a/internal/home/id_exchange_test.go b/internal/home/id_exchange_test.go
index f201db2..83f99b4 100644
--- a/internal/home/id_exchange_test.go
+++ b/internal/home/id_exchange_test.go
@@ -1,14 +1,17 @@
package home
import (
+ "amadan.net/oficina/home/handoff"
"amadan.net/rastrillo/rastrillo/assertion"
"amadan.net/rastrillo/rastrillo/sessions"
"encoding/base64"
"encoding/json"
"github.com/keymaildev/signin"
+ "html"
"net/http"
"net/http/httptest"
"net/url"
+ "regexp"
"strings"
"testing"
"time"
@@ -29,21 +32,181 @@ func TestIDLinkAlwaysRequiresNewGesture(t *testing.T) {
}
}
-func TestIDContinueBeforeMinting(t *testing.T) {
+// TestIDStraightIn is Paul's straight-in ruling (2026-11-20; slice 1
+// spec, Assertion and browser exchange, step 2): with an id.* session
+// and no forced authentication, the GET that lands on /authorize/resume
+// mints and renders the form-POST delivery itself, with no Continue page.
+// The assertion rides only the form body: never the URL, a redirect or a
+// log line.
+func TestIDStraightIn(t *testing.T) {
p := newExchangePair(t)
session := signInFully(t, p.credential, sealtest.CanaryAddress)
- _, intent := p.start(t)
+ pending, intent := p.start(t)
r := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent, session)
- if r.Code != 200 || strings.Contains(r.Body.String(), `name="assertion"`) || !strings.Contains(r.Body.String(), `action="/authorize/resume"`) {
- t.Fatal("GET did not stop at Continue", r.Code)
+ body := r.Body.String()
+ m := regexp.MustCompile(`name="assertion" value="([^"]+)"`).FindStringSubmatch(body)
+ if r.Code != 200 || len(m) != 2 {
+ t.Fatal("GET did not go straight in", r.Code)
+ }
+ token := html.UnescapeString(m[1])
+ if strings.Contains(body, `action="/authorize/resume"`) || strings.Contains(body, "Continue to the app") {
+ t.Fatal("the Continue page is still drawn")
+ }
+ // The delivery is the hop: auto-submit, with Continue for script-off.
+ for _, want := range []string{`action="` + directoryOrigin + handoff.CallbackPath + `"`, `data-assertion-handoff`, `<button type="submit" rst-btn="primary">Continue</button>`, versioned("/static/assertion.js")} {
+ if !strings.Contains(body, want) {
+ t.Fatalf("delivery lacks %q", want)
+ }
+ }
+ if r.Header().Get("Cache-Control") != "no-store" || r.Header().Get("Referrer-Policy") != "strict-origin-when-cross-origin" || r.Header().Get("Location") != "" {
+ t.Fatal("delivery headers changed", r.Header())
+ }
+ cleared := false
+ for _, c := range r.Result().Cookies() {
+ cleared = cleared || (c.Name == assertionIntentCookie && c.MaxAge < 0)
+ }
+ if !cleared {
+ t.Fatal("intent survived the mint")
+ }
+ for _, h := range r.Header().Values("Set-Cookie") {
+ if strings.Contains(h, token) {
+ t.Fatal("assertion in a cookie")
+ }
+ }
+ if strings.Contains(p.logs.String(), token) || strings.Contains(p.logs.String(), sealtest.CanaryAddress) {
+ t.Fatal("assertion or address in the logs")
+ }
+ // And it finishes: the app's callback takes it.
+ if p.finish(t, token, pending) == nil {
+ t.Fatal("no app session")
+ }
+ // The POST still mints, for a Continue page left open in a tab, and
+ // still behind csrf.Protect.
+ _, again := p.start(t)
+ if bad := exchangeRequest(p.credential.App, "POST", Origin+"/authorize/resume", "https://evil.invalid", url.Values{}, again, session); bad.Code != 403 {
+ t.Fatal("POST lacks CSRF protection", bad.Code)
+ }
+ if good := exchangeRequest(p.credential.App, "POST", Origin+"/authorize/resume", Origin, url.Values{}, again, session); good.Code != 200 || !strings.Contains(good.Body.String(), `name="assertion"`) {
+ t.Fatal("POST did not mint", good.Code)
+ }
+}
+
+// TestIDStraightInForeignNonceRefusedAtFinish: an assertion the
+// straight-in GET minted for a nonce that is not this browser's pending
+// one (another browser's, or one made up and sent to /authorize) never
+// signs this browser in at the app: the app's finish refuses it.
+func TestIDStraightInForeignNonceRefusedAtFinish(t *testing.T) {
+ p := newExchangePair(t)
+ session := signInFully(t, p.credential, sealtest.CanaryAddress)
+ pending, _ := p.start(t)
+ _, otherIntent := p.start(t)
+ junk := exchangeRequest(p.credential.App, "GET", Origin+"/authorize?consumer=directory&nonce="+base64.RawURLEncoding.EncodeToString(make([]byte, 16)), "", nil, session)
+ if junk.Code != http.StatusSeeOther {
+ t.Fatal("junk authorize", junk.Code)
+ }
+ for name, intent := range map[string]*http.Cookie{"another browser's nonce": otherIntent, "a made-up nonce": namedCookie(t, junk, assertionIntentCookie)} {
+ t.Run(name, func(t *testing.T) {
+ r := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent, session)
+ m := regexp.MustCompile(`name="assertion" value="([^"]+)"`).FindStringSubmatch(r.Body.String())
+ if r.Code != 200 || len(m) != 2 {
+ t.Fatal("no straight-in mint", r.Code)
+ }
+ callback := exchangeRequest(p.directory, "POST", directoryOrigin+handoff.CallbackPath, Origin, url.Values{"assertion": {html.UnescapeString(m[1])}})
+ if sessionCookie(callback) != nil {
+ t.Fatal("the callback minted a session")
+ }
+ cookies := []*http.Cookie{pending}
+ for _, c := range callback.Result().Cookies() {
+ if c.Name == "__Host-oficina-assertion-inbox" && c.Value != "" {
+ cookies = append(cookies, c)
+ }
+ }
+ finish := exchangeRequest(p.directory, "GET", directoryOrigin+handoff.FinishPath, "", nil, cookies...)
+ if sessionCookie(finish) != nil || finish.Header().Get("Location") == "/?team=blue" {
+ t.Fatal("a foreign nonce signed this browser in", finish.Code)
+ }
+ })
+ }
+}
+
+// TestIDStraightInMintsOnlyForANavigation: the minting GET refuses a
+// prefetch or prerender, and anything a browser says is not a top-level
+// document navigation; a browser that sends no Sec-Fetch headers is
+// judged on the purpose headers alone.
+func TestIDStraightInMintsOnlyForANavigation(t *testing.T) {
+ p := newExchangePair(t)
+ session := signInFully(t, p.credential, sealtest.CanaryAddress)
+ _, intent := p.start(t)
+ navigate := map[string]string{"Sec-Fetch-Mode": "navigate", "Sec-Fetch-Dest": "document", "Sec-Fetch-Site": "cross-site"}
+ with := func(base map[string]string, k, v string) map[string]string {
+ out := map[string]string{}
+ for a, b := range base {
+ out[a] = b
+ }
+ if v == "" {
+ delete(out, k)
+ } else {
+ out[k] = v
+ }
+ return out
+ }
+ get := func(headers map[string]string) *httptest.ResponseRecorder {
+ r := httptest.NewRequest("GET", Origin+"/authorize/resume", nil)
+ r.AddCookie(intent)
+ r.AddCookie(session)
+ for k, v := range headers {
+ r.Header.Set(k, v)
+ }
+ w := httptest.NewRecorder()
+ p.credential.Router().ServeHTTP(w, r)
+ return w
+ }
+ for name, headers := range map[string]map[string]string{
+ "prefetch": with(navigate, "Sec-Purpose", "prefetch"),
+ "prerender": with(navigate, "Sec-Purpose", "prefetch;prerender"),
+ "legacy prefetch": {"Purpose": "prefetch"},
+ "fetch()": with(with(navigate, "Sec-Fetch-Mode", "cors"), "Sec-Fetch-Dest", "empty"),
+ "no-cors": with(with(navigate, "Sec-Fetch-Mode", "no-cors"), "Sec-Fetch-Dest", "image"),
+ "iframe": with(navigate, "Sec-Fetch-Dest", "iframe"),
+ "mode without dest": with(navigate, "Sec-Fetch-Dest", ""),
+ "dest without mode": with(navigate, "Sec-Fetch-Mode", ""),
+ } {
+ if r := get(headers); r.Code == 200 || strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Errorf("%s minted: %d", name, r.Code)
+ }
+ }
+ for name, headers := range map[string]map[string]string{"navigation": navigate, "no Sec-Fetch headers": {}} {
+ if r := get(headers); r.Code != 200 || !strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Errorf("%s did not mint: %d", name, r.Code)
+ }
}
- bad := exchangeRequest(p.credential.App, "POST", Origin+"/authorize/resume", "https://evil.invalid", url.Values{}, intent, session)
- if bad.Code != 403 {
- t.Fatal("Continue lacks CSRF protection", bad.Code)
+}
+
+// TestIDStraightInWithoutSessionIsTheDoor: no id.* session, no mint; the
+// sign-in door, coming back to the resume.
+func TestIDStraightInWithoutSessionIsTheDoor(t *testing.T) {
+ p := newExchangePair(t)
+ _, intent := p.start(t)
+ r := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent)
+ if r.Code != http.StatusSeeOther || !strings.HasPrefix(r.Header().Get("Location"), "/signin") || strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Fatal("no session did not go to the door", r.Code, r.Header().Get("Location"))
+ }
+}
+
+// TestIDStraightInNeverSkipsForcedAuthentication: a link or a step-up
+// (max_age=300) on a standing session, however recent, still goes to the
+// door for a new gesture; after that gesture the GET goes straight in.
+func TestIDStraightInNeverSkipsForcedAuthentication(t *testing.T) {
+ p := newExchangePair(t)
+ session := signInFully(t, p.credential, sealtest.CanaryAddress)
+ _, intent := p.startFresh(t, session)
+ r := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent, session)
+ if r.Code != http.StatusSeeOther || !strings.HasPrefix(r.Header().Get("Location"), "/signin?") || strings.Contains(r.Body.String(), `name="assertion"`) {
+ t.Fatal("forced authentication was skipped", r.Code)
}
- good := exchangeRequest(p.credential.App, "POST", Origin+"/authorize/resume", Origin, url.Values{}, intent, session)
- if good.Code != 200 || !strings.Contains(good.Body.String(), `name="assertion"`) {
- t.Fatal("Continue did not mint", good.Code)
+ fresh := signInFully(t, p.credential, sealtest.CanaryAddress)
+ if after := exchangeRequest(p.credential.App, "GET", Origin+"/authorize/resume", "", nil, intent, fresh); after.Code != 200 || !strings.Contains(after.Body.String(), `name="assertion"`) {
+ t.Fatal("a fresh gesture did not go straight in", after.Code)
}
}
diff --git a/internal/home/render.go b/internal/home/render.go
index e5e645d..7d488ec 100644
--- a/internal/home/render.go
+++ b/internal/home/render.go
@@ -140,7 +140,7 @@ func (a *App) renderPage(w http.ResponseWriter, r *http.Request, status int, nam
// renderFailed answers a page that could not be drawn: the 500 page,
// unless the page that failed was the error page itself.
func (a *App) renderFailed(w http.ResponseWriter, r *http.Request, name string) {
- if name == "error.html" || r == nil {
+ if name == "error.html" || name == "id_error.html" || r == nil {
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
diff --git a/internal/home/shared_chrome_test.go b/internal/home/shared_chrome_test.go
index 1731934..712c3ca 100644
--- a/internal/home/shared_chrome_test.go
+++ b/internal/home/shared_chrome_test.go
@@ -366,8 +366,14 @@ func TestErrorPagesSplitByAccept(t *testing.T) {
if rec.Code != http.StatusNotFound || !strings.HasPrefix(rec.Header().Get("Content-Type"), "text/html") {
t.Fatalf("browser: %d %q, want a 404 page", rec.Code, rec.Header().Get("Content-Type"))
}
- if titleOf(body) != "Page not found · Oficina" || !strings.Contains(body, "<div rst-error>") || !strings.Contains(body, "We can’t find that page") || !strings.Contains(body, "<header estilo-bar") {
- t.Errorf("not estilo's error page under the bar: %q", titleOf(body))
+ // On id.* the same words sit in the door's card, branded
+ // Oficina ID (Paul, 2026-11-20: every id.* page in the card).
+ onID := strings.HasPrefix(c.name, "id.*")
+ if titleOf(body) != "Page not found · Oficina" || strings.Contains(body, "<div rst-error>") == onID || !strings.Contains(body, "We can’t find that page") || !strings.Contains(body, "<header estilo-bar") {
+ t.Errorf("not the error page under the bar: %q", titleOf(body))
+ }
+ if onID && (!strings.Contains(body, "<div estilo-door estilo-sky-host>") || !strings.Contains(body, "<span>Oficina ID</span>") || !strings.Contains(body, `<a rst-btn="primary" href="`+directoryOrigin+`/">Go to Oficina</a>`)) {
+ t.Errorf("id.*'s error page is not in the door's card:\n%s", body)
}
if got := strings.Contains(body, "<details estilo-account"); got != c.account {
t.Errorf("account menu %v, want %v", got, c.account)
diff --git a/internal/home/static/handoff-noscript.css b/internal/home/static/handoff-noscript.css
index 710cab1..8b5ea44 100644
--- a/internal/home/static/handoff-noscript.css
+++ b/internal/home/static/handoff-noscript.css
@@ -1,3 +1,3 @@
/* With scripts off nothing submits, so the hand-off card shows at once.
Linked inside <noscript> on each hop page. */
-[estilo-handoff] { animation: none; }
+[estilo-door] > [estilo-signin] { animation: none; }
diff --git a/internal/home/static/handoff.css b/internal/home/static/handoff.css
index b16dd63..e506985 100644
--- a/internal/home/static/handoff.css
+++ b/internal/home/static/handoff.css
@@ -2,6 +2,8 @@
so the card stays hidden for 1.5 s and shows only if the submit stalls
(spec shared-chrome §9.3). Linked from each hop page's head. A file, not
a <style> block: rastrillo's default CSP, which Home keeps, allows no
- inline style since v0.27.0. */
-[estilo-handoff] { animation: estilo-reveal 0s 1.5s both; }
+ inline style since v0.27.0. The card is the door's (estilo-door-open,
+ with the brand at its head); this file is linked only from hop pages,
+ so the rule hides no other page's card. */
+[estilo-door] > [estilo-signin] { animation: estilo-reveal 0s 1.5s both; }
@keyframes estilo-reveal { from { visibility: hidden } to { visibility: visible } }
diff --git a/internal/home/templates/id_continue.html b/internal/home/templates/id_continue.html
deleted file mode 100644
index 90e4f07..0000000
--- a/internal/home/templates/id_continue.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{{define "title"}}Continue to the app · Oficina{{end}}
-{{define "content"}}
-<h1>Continue to the app</h1>
-<form method="post" action="/authorize/resume" rst-form>
-<button type="submit" rst-btn="primary">Continue</button>
-</form>
-{{end}}
diff --git a/internal/home/templates/id_error.html b/internal/home/templates/id_error.html
new file mode 100644
index 0000000..34d2add
--- /dev/null
+++ b/internal/home/templates/id_error.html
@@ -0,0 +1,14 @@
+{{define "title"}}{{.Data.Title}}{{end}}
+{{define "content"}}
+{{/* estilo-error's words (chrome.ErrorPage) in the door's card, on id.*
+ only (chrome.go, errorPage). */}}
+{{- with .Data.Error}}
+<h1>{{.Title}}</h1>
+<p estilo-signin-body>{{.Body}}</p>
+<p><a rst-btn="primary" href="{{.Home.Href}}">{{.Home.Label}}</a>
+ {{- with .Back}} <a rst-btn href="{{.Href}}">{{.Label}}</a>{{end}}</p>
+{{- with .Ref}}
+<p class="rst-mono" dir="auto">{{$.Data.Error.RefLabel}} {{.}}</p>
+{{- end}}
+{{- end}}
+{{end}}
diff --git a/internal/home/templates/layout.html b/internal/home/templates/layout.html
index cc18c18..18be9e3 100644
--- a/internal/home/templates/layout.html
+++ b/internal/home/templates/layout.html
@@ -30,16 +30,13 @@
{{template "estilo-bar" .Chrome}}
<main rst-page id="main">
{{- if door}}
-{{template "estilo-door-open" doorView}}
+{{template "estilo-door-open" (doorView .Brand)}}
{{template "content" .}}
{{template "estilo-door-close"}}
{{- else if hop}}
-<div estilo-door estilo-sky-host>
-{{template "estilo-sky" hopSky}}
-<section estilo-signin estilo-handoff>
+{{template "estilo-door-open" (hopDoor .Brand)}}
{{template "content" .}}
-</section>
-</div>
+{{template "estilo-door-close"}}
{{- else}}
{{template "content" .}}
{{- end}}