oficina / home Public

Design Oficina ID slice 1 with optional app sign-in

Specify both local and Oficina ID sign-in, explicit account linking, recovery, external consumers and key rotation. Keep three owner policy decisions open.

Independently reviewed by GPT-6 Astra (gpt-6-astra); acceptable as a design proposal after unlink-race and key-cache corrections. No implementation, deployment or merge approval.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9792f186638c91e7971cc183249e60903e5b0beb parent 14c83d7
1 file changed, +100 −0
  • docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md +100 −0

CI cancelled — superseded by a newer push — run details

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
new file mode 100644
index 0000000..310b809
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-13-oficina-id-slice-1.md
@@ -0,0 +1,100 @@
+# 🤖 Oficina ID: slice 1
+
+Status: design proposal, 2026-11-13; independently reviewed by GPT-6 Astra (`gpt-6-astra`), acceptable as a proposal after corrections; no blocking findings remain. Paul’s three policy decisions remain open. No implementation, deployment or merge approval. Author: Codex. Base: Home `14c83d7`.
+
+## Decision and boundary
+
+**Paul, 2026-11-13:** every Oficina app keeps its own sign-in **and** offers “Sign in with Oficina ID”. Contra (`carlos/contra`) and Equipo (`oficina/equipo`) come first; Docs, Sheets and Slides follow. Local sign-in must remain reachable without contacting Home, including for linked accounts.
+
+This slice supplies credential sign-in, recovery, signed identity handoffs, explicit account linking/unlinking and published verification keys. Directory, provisioning, roster changes and preferences beyond display are outside it. An ID assertion grants no team membership, invitation acceptance or item access.
+
+This proposal extends [Home §4–5](2026-08-30-home-design.md): standalone passkey authentication supplements the current second-factor gate; key publication supplements the current pinned-key transport. These changes need approval before implementation. Existing roster rules remain binding on consumers that already use them; this slice introduces no roster dependency for Contra or Equipo.
+
+## Evidence and domains
+
+Read against Home `14c83d7`, `connect/README.md`, `handoff/`, the credential-return and transactional-link-resolution specs, suite README, Equipo's `internal/equipo/auth.go` and `setup/session_handlers.go`, and Contra's README and `internal/contra/auth/auth.go`.
+
+Home already signs P-256 assertions, implements browser-bound handoff and provides an explicit linking bridge. Commit `0dc863c` merged assertion exchange; `47301e8` requires actual fresh authentication. `462df84` records the primary-domain decision; `243c2d4` and `7bdddfa` confirm its public apex and credential-host split. Older plans describing Ed25519 or an unbuilt exchange are historical.
+
+The credential origin and issuer are [https://id.oficina.works](https://id.oficina.works); the WebAuthn relying-party ID is exactly **id.oficina.works**, never `oficina.works`. The directory is [https://oficina.works](https://oficina.works). Team apps use `<team>.<app>.oficina.works`. Credentials, recovery and assertion minting stay on the credential origin, which never renders account-authored names, addresses or other strings. Use fixed service labels and generated identifiers. Cookies are host-only, Secure and HttpOnly; no parent-domain session cookie.
+
+An operator registers each consumer ID against one exact canonical HTTPS origin, identifying both app and instance. Return only to its fixed `/auth/assertion` path. No wildcard, suffix trust, request-supplied redirect URL or automatic registration. Registration is configuration in this slice, independent of provisioning.
+
+Contra's actual production HTTPS origin can be registered outside `oficina.works`; no domain move, shared cookie or cross-origin browser API is required. Alias hosts do not become alternate audiences. Native deep-link delivery is outside this browser slice.
+
+## Home sign-in and recovery
+
+Offer direct passkey sign-in and email sign-in. First registration verifies the mailbox through Keymail or an emailed link, then allocates/reuses an opaque person ref through Home's existing normalized, peppered address index. The pepper never leaves Home. Do not infer identity from an unverified address or normalize differently between registration and return visits.
+
+Direct passkey sign-in uses a discoverable credential whose user handle identifies the person ref. Require user verification, exact origin/RP checks, a five-minute browser-bound single-use challenge and the stored credential-to-person binding. No email step is needed for this path. Existing nondiscoverable credentials retain their current gated sign-in path until fresh authentication permits enrolling a discoverable replacement. Enrollment requires fresh authentication, request-forgery protection and binding to that same person. Never widen `LegacyRPID` for this feature.
+
+For email, keep Home's `keymaildev/signin.Flow`: Keymail upgrade for supported inboxes, platform SMTP for emailed links, and explicit email fallback when classification or Keymail fails. Rate-limit by IP and blinded address; responses must not disclose account existence. SMTP failure yields a retryable failure, never successful authentication. GET displays link confirmation; POST redeems once, with the existing confirmation/browser protections. Completing email in another browser cannot complete the original app's handoff: restart there.
+
+Equipo currently uses `rastrillo/auth`, verified active membership or a pending invitation, normalized email subjects and configured mail delivery. Preserve that local path. Home cannot copy its storage: at Home's pin `29e4491`, `auth.Config.SubjectFor` **does exist**, contrary to the older binding text, but `auth.New` still installs a link store writing `auth_links.address`. A subject hook alone does not make it safe. Keep Home's sealed link store and opaque session subjects; reconcile the stale hook statement when this proposal is approved.
+
+Seal addresses before any persistent link write; bound retention by link expiry. No readable-address column, log, error, metric, queue payload or backup; keep `secure_delete` enabled and scan SQLite, WAL and store objects. Session, passkey and recovery subjects are person refs. Home's key is not shared with Contra's independent local blind index.
+
+Recommended recovery policy preserves the existing enrolled-account gate: after enrolling a passkey, email/Keymail sign-in still requires that passkey or a recovery code. Mailbox compromise must not silently remove the factor. Issue ten hashed, single-use recovery codes, shown once; email proof plus a code restores sign-in when the passkey is lost. Codes work by ordinary form POST. A direct passkey still works after mailbox loss. With no working permitted path, access is lost; no operator reset.
+
+Recovery does not satisfy operations requiring a real passkey step-up. Replacing a lost last passkey under recovery needs an explicit policy decision below; do not disguise it as ordinary freshness. Preserve the person ref across recovery. Email, recovery and handoff work without scripts; only the WebAuthn ceremony requires them.
+
+## Assertion and browser exchange
+
+Reuse `rastrillo/assertion` version 1: P-256, context `rastrillo/assertion/v1`, `base64url(payload).base64url(signature)`. Do not introduce JWT, algorithm negotiation or app-specific verifiers.
+
+| Claim | Consumer interpretation |
+|---|---|
+| `v`, `kid` | Fixed wire version; key from the configured issuer's trusted key set. |
+| `iss`, `aud` | Exact credential origin and exact registered consumer origin. |
+| `sub` | Stable opaque Home person ref; resolve through this app's explicit link. |
+| `iat`, `exp` | Mint for exactly 120 seconds. Require positive lifetime at most 120 seconds, `exp > now`, and `iat <= now + 30 seconds`. No expiry grace. |
+| `jti`, `nonce` | Independent random identifiers: replay prevention and browser-transaction binding. |
+| `auth_time` | Actual credential authentication time; handoff never refreshes it. It proves recency, not factor strength or authorization. |
+| `ext` | Omit initially. Future display values require a closed enum already held by Home; unknown values mean absent. |
+
+No email, role, team grant, plan, document list, encryption key or authentication-strength claim. Signed identity is trusted for identity; cosmetic values cannot affect admission. Existing roster hints, if introduced separately, remain invalidation-only under Home §5.4.
+
+1. The app stores a short-lived transaction with an independent random browser secret, nonce, purpose and validated local return path/query. It sets a `__Host-` pending cookie and redirects to `/authorize?consumer=…&nonce=…`. The target document, local account and privileges remain app-side.
+2. Home validates the consumer, authenticates the person and POSTs the signed assertion to that consumer's fixed callback. Use the current form with optional static auto-submit and a manual Continue button. No assertion in URL, history, referrer or logs; responses are `no-store`. Preserve `strict-origin-when-cross-origin` on delivery: `no-referrer` can null the POST Origin.
+3. The callback accepts only a bounded form POST with the exact issuer `Origin`. Verify signature, issuer, audience, types and times; reserve `(iss,jti)` uniquely in the inbox so repeated callbacks refuse. Storage failure refuses.
+4. Reuse `handoff`'s two-stage return: callback stores a sealed, expiring inbox receipt and redirects to `/auth/finish`; the top-level GET receives the original SameSite=Lax cookie, validates the browser secret and consumes the transaction. Recheck expiry and the signed nonce there; atomically consume the inbox and pending transaction and persist `(iss,jti)` replay consumption before minting. Preserve the existing clock watermark and replay retention through expiry plus thirty seconds across restarts. Only then resolve the link and mint an app session. Never mint at the cross-site POST, where Lax cookies may be absent.
+
+Reject swapped browsers, sessions, nonces, purposes and accounts. A valid assertion must not silently replace a different signed-in app account. The callback is the sole narrow cross-origin request-forgery exception. Safe local return paths preserve their query locally; Home receives no resource URL. Bound pending/inbox rows and prune on writes and startup.
+
+## Linking and unlinking
+
+Store the mapping **in the sibling**: `(issuer, person_ref) → immutable local account ID`. Enforce uniqueness in both directions within that app instance. Nothing about the local account is sent to Home. Equal email addresses never create, repair or transfer a link.
+
+Linking starts from the actual local session with request-forgery protection. Require genuine local reauthentication and Home authentication within five minutes, both still fresh at confirmation. Use Home's existing `max_age=300` flow and actual `auth_time`; a silent Keymail session is not fresh proof. Bind the proof to the original local account, session, nonce and purpose. Show confirmation on the sibling, then consume both proofs and write the link in one transaction, rechecking current account existence and admission. Conflict means refusal, never merge or overwrite.
+
+Use `connect`/`linkstore`'s existing proof stages. Equipo resolves Home subjects to its existing member identity before applying its active-member, invitation and session-epoch checks. Never send a Home ref into its address-based helpers. An unlinked ID returns to local sign-in and explicit linking; it does not allocate a duplicate account or accept an invitation.
+
+Contra needs a reviewed adapter: today's `connect.LookupPerson` requires a verified address label and integer ID, while Contra uses opaque account IDs and no readable address. Preserve proof binding and nonreuse checks against its immutable local account identifier; never invent an address or relax the bridge globally. ID sign-in creates only a locked, identity-authenticated app session. Unlock, enrollment of devices, key changes and destructive vault operations retain Contra's own cryptographic proofs. Home receives no passphrase, Account Key, recovery sheet, vault key or plaintext. Recovering Oficina ID cannot recover a vault.
+
+Unlink requires fresh **local** authentication and explicit protected confirmation; it works while Home is down. Atomically delete the mapping, invalidate all pending link proofs and advance a persistent per-account link generation. Resolve Home-derived sessions against the current mapping and generation on every request, including before writes; revoke them on unlink. A later relink cannot revive old sessions. Fence ordinary handoffs too: save a global monotonic revision at each start and record the account’s last-unlink revision. Refuse completion if unlink occurred since that start, even after relink. Check mapping/generation inside the session-creation transaction and every protected-write transaction. Retain local credentials, local sessions and data. An assertion arriving afterward is unlinked and cannot reconnect automatically. Deleting the local account removes its links transactionally; identifiers are never reused. Address changes under today's address-bound bridge require fresh linking.
+
+## Published keys and rotation
+
+Propose `GET /.well-known/oficina-id-keys` on the credential origin: JSON shaped as `{v:1, iss, keys:[{kid,pub}]}`, containing the exact issuer and up to eight unique `kid` entries; `pub` is the base64url 65-byte uncompressed P-256 public key. Bound response size to 16 KiB; reject malformed points, duplicates and unknown versions. Private signing keys remain credential-only platform secrets.
+
+Consumers configure the issuer and fixed endpoint out of band. Fetch over authenticated HTTPS with no redirects; never follow token-supplied key URLs. This explicitly extends today's pinned-key-only transport. Add a shared refresh seam to `handoff` and replace its immutable verifier after validating the complete document; do not implement fetching separately in each app. TLS at that origin is the discovery trust anchor; possession of a self-published key alone proves nothing.
+
+Publish with `Cache-Control: no-store`; fetch with cache bypass and no stale-response fallback. Only a fresh origin response renews the trust deadline; stale intermediary responses cannot extend it. Revalidate key trust at `/auth/finish`. Refresh after five minutes. Permit a last-good set for at most fifteen minutes since successful fetch; a cache hit or restart cannot renew that deadline. Refetch once on unknown `kid`, coalesced and rate-limited, then fail closed. Expired/missing keys disable ID exchange only. Bootstrap pins may seed a cache but must obey the same deadline; retired pins cannot override a newer set.
+
+Prepublish a new key for fifteen minutes plus thirty seconds before signing with it. Keep the previous public key for at least 150 seconds after its last assertion, then remove it. Retention is a fixed horizon, never waiting for every hibernating consumer. A cold consumer fetches before exchanging; inability to refresh fails closed.
+
+On compromise, remove the key immediately and stop signing with it. Cached acceptance can persist for fifteen minutes; notify operators to disable the affected key sooner. Existing app sessions are not retroactively revoked by key removal: incident response must revoke affected Home-derived sessions separately. Never disable local sign-in as a rotation mechanism.
+
+## Failures and acceptance
+
+Home outage prevents new ID authentication, fresh linking and expired-key refresh. Existing app sessions continue under local expiry, revocation and admission checks. Local sign-in and unlink remain usable. Home logout ends Home's session; app logout must always revoke locally even if its subsequent Home logout fails. No global logout guarantee.
+
+Reject bad audiences, unknown keys, replay, stale proofs and storage failures without account changes. Offer local sign-in or a deliberate retry, without automatic redirect loops. A deleted link cannot be reconstructed from email.
+
+Before implementation approval, require gates for the exact RP/origin split, no account-authored credential rendering, address-at-rest/log scans, both sign-in paths and recovery, expired/replayed/swapped handoffs, real cross-site scriptless delivery, concurrent link/unlink/relink, rotation and outage. Contra additionally proves ID recovery cannot decrypt or replace vault keys; Equipo proves identical local admission checks through either sign-in path.
+
+## Questions only Paul can answer
+
+1. **May recovery replace the last lost passkey?** Recommend a narrowly scoped email-plus-code replacement ceremony, retaining the separate ban on recovery satisfying unrelated passkey-only step-up. Without it, recovery restores sessions but cannot repair the lost credential.
+2. **Is fifteen minutes of cached-key trust acceptable after compromise?** Recommend this bound for outage tolerance, with explicit emergency session revocation; shorter bounds increase Home availability dependence.
+3. **May voluntary linking expose Contra's account-to-Home-ref association at rest?** Recommend explicit opt-in and disclosure. Content stays encrypted, but cross-service identity correlation is new metadata and requires a Contra threat-model amendment before integration.