oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

🤖 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. 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

Paul, 2026-11-13: every Oficina app keeps its own sign-in and offers “Sign in with Oficina ID”. Slice 1 is Home plus Equipo only. Contra adopts in slice 2; Docs, Sheets and Slides follow. Local sign-in remains reachable without contacting Home, including for linked accounts.

Slice 1 covers passkey/email sign-in, recovery, signed identity handoffs, explicit linking/unlinking and configured verification keys. Directory, provisioning, roster changes and preferences beyond display are outside it. Assertions grant no membership, invitation acceptance or item access. Existing roster rules remain binding where already used; Equipo gains no roster dependency here.

This design extends Home §4–5 with standalone passkeys and Paul's recovery replacement ruling. Key publication is later work. The former cached-key proposal is withdrawn.

Evidence, domains and registration

Checked against Home 14c83d7, connect, handoff, the credential-return and transactional-link-resolution specs, suite README, Equipo's auth.go and setup/session_handlers.go, and pinned rastrillo 29e4491. Home already implements P-256 assertions and explicit linking. Commit 462df84 records the primary-domain decision; 0dc863c merged assertion exchange and 47301e8 tightened freshness. Older Ed25519 plans are historical.

The issuer is https://id.oficina.works, and the WebAuthn relying-party ID is exactly id.oficina.works, never the parent domain. The directory is https://oficina.works; team apps use <team>.<app>.oficina.works. Credential pages never render account-authored strings. Cookies are host-only, Secure and HttpOnly; no parent-domain session cookie.

Registration uses existing HOME_CONSUMERS: a JSON object mapping consumer IDs to exact canonical HTTPS origins. Equivalently, HOME_CONSUMERS_BASE64 contains standard-base64 encoding of that JSON; set only one. Keep the required directory entry pointing at the configured directory origin and add Equipo's consumer/origin entry. The environment manifest permits 1–16 entries, at most 8,192 decoded bytes; IDs are 1–64 ASCII letters, digits, underscores or hyphens. Refuse collisions with existing database registrations.

Each origin identifies one app instance, with fixed callback /auth/assertion. No wildcard, suffix trust, arbitrary return URL or automatic registration. Alias hosts are separate audiences. External HTTPS consumers need no domain move or shared cookies, but their pairwise-subject policy belongs to later slices. Native deep-link delivery is outside this browser slice.

Home sign-in and recovery

Offer direct passkey 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 normalized, peppered index. The pepper stays at Home. Never resolve from an unverified address or use different normalization on return visits.

Direct passkey sign-in uses a discoverable credential bound to the person ref. WebAuthn user.id is an opaque handle; user.name and user.displayName are generated identifiers, never an address or entered name. Require user verification, exact origin/RP checks, a five-minute browser-bound single-use challenge and the stored credential/person binding. Enrollment requires fresh authentication and request-forgery protection. Existing nondiscoverable credentials retain gated sign-in until a discoverable replacement is enrolled. Keep LegacyRPID unchanged.

Keep Home's keymaildev/signin.Flow: Keymail upgrade, platform SMTP for emailed links, explicit email fallback after classification/Keymail failure. Rate-limit by IP and blinded address without disclosing account existence. SMTP failure never authenticates. GET displays confirmation; POST redeems once with existing browser protections. Email completed in another browser cannot finish the original app's handoff; restart there.

Equipo keeps its existing rastrillo/auth local path and active-member/invitation checks. At pin 29e4491, auth.Config.SubjectFor exists, but auth.New still installs the readable auth_links.address store. The corrected AGENTS.md records this: a subject hook alone is insufficient. Home keeps its sealed link store and opaque session subjects.

Seal addresses before persistent link writes; expire the sealed state. No readable-address column, log, error, metric or queue payload. Keep secure_delete and scan SQLite, WAL, store objects and backups. Sessions, passkeys and codes key on person refs.

After passkey enrollment, email/Keymail sign-in requires a passkey or recovery code. Issue ten hashed, single-use codes, shown once, each with at least 80 bits of random entropy. Code redemption is a protected form POST. Limit failed attempts persistently and atomically per account and IP: initially five per account and twenty per IP per fifteen minutes. Neither restart nor parallel requests resets the allowance.

Paul's ruling: email plus a recovery code is full account control. It can replace the last lost passkey. Require fresh mailbox proof and an unused code bound to the same person and browser; provide an explicit replacement confirmation. Verify the new passkey ceremony, then atomically install that credential, consume the recovery proof, remove all previous passkeys, revoke all Home sessions and invalidate every remaining recovery code. Failure rolls back replacement; success requires a new sign-in with the new passkey. Generate replacement codes only after that proof.

Send a replacement notice to the just-proven address held in memory, without storing it or adding it to a retry queue. Delivery failure must not undo revocation; allow a retry while the address remains available and report only a content-free failure. Recovery cannot satisfy unrelated passkey-only step-up. A working passkey survives mailbox loss; with no permitted recovery path, access is lost. No operator reset. Email/recovery work without scripts; WebAuthn requires its ceremony script.

Assertion and browser exchange

Reuse rastrillo/assertion v1: P-256, context rastrillo/assertion/v1, base64url(payload).base64url(signature). No JWT, algorithm negotiation or separate app verifiers.

| Claim | Interpretation | |---|---| | v, kid | Fixed wire version and configured pinned verification key. | | iss, aud | Exact credential origin and registered app-instance origin. | | sub | Stable opaque Home person ref for Equipo; resolve through its explicit link. | | iat, exp | Mint for 120 seconds; require positive lifetime at most 120, exp > now, iat <= now + 30 seconds. No expiry grace. | | jti, nonce | Independent random replay identifier and browser-transaction nonce. | | auth_time | Actual authentication time, never refreshed by handoff; recency grants no authorization or factor strength. | | ext | Omit initially; future cosmetic values require closed enums already held by Home, unknown values treated as absent. |

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, 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

The sibling stores (issuer, person_ref) → immutable local account ID, unique in both directions within its instance. Nothing about that account goes to Home. Email equality never creates, repairs or transfers a link.

Start from the actual local session with request-forgery protection. Equipo completes local reauthentication before creating the link transaction and starting the Home leg. Record the transaction start server-side. Both proofs must be within five minutes at confirmation, and Home's auth_time must be at or after that start, with no backward allowance. Bind proofs to the original local account, session, nonce and purpose; never restart the clock by continuing a stale flow.

max_age=300 alone currently permits session reuse. For this slice, these requests must force a new Home authentication gesture, even with a recent session; a passive Keymail approval is insufficient. The consumer independently rejects an older auth_time. This tightens issuance behavior without adding request parameters. Show confirmation on Equipo, then consume both proofs and write the link in one transaction, rechecking existence/admission. Conflict refuses; never merge or overwrite.

Retain connect/linkstore's proof stages. Resolve Home subjects to Equipo's member identity before its active-member, invitation and session-epoch checks. Never pass a person ref to address-based helpers. An unlinked ID returns to local sign-in/linking; no duplicate account or implicit invitation acceptance.

Unlink requires fresh local authentication and protected confirmation, and works while Home is down. In one transaction delete the mapping, every Home-derived session for it, and pending link/handoff proofs and receipts. Anonymous pending flows cannot yet be attributed: clear the instance's bounded pending/inbox/link-proof sets rather than add revision machinery. Other in-progress sign-ins may need restarting. Serialize callback receipt insertion, completion/session minting, linking and unlinking through the database writer; minting checks the live mapping in that same transaction. A later relink cannot revive deleted proofs or sessions. Keep local credentials, local sessions and data. Account deletion removes links transactionally; IDs are never reused. Address changes under today's address-bound bridge require fresh linking.

Pinned keys and rotation

Use connect's existing EQUIPO_HOME_ISSUER, EQUIPO_HOME_CONSUMER_ID, EQUIPO_HOME_KEYS_BASE64 and EQUIPO_HOME_DEK_BASE64. The keys value is standard-base64 JSON mapping kid to standard-base64 65-byte uncompressed P-256 public keys, at most eight keys/4,096 decoded bytes. The dedicated 32-byte storage key protects handoff/link state, not content; keep it stable. Unknown kid fails closed without fetching. Private signing keys stay in credential-only configuration.

Rotate by configuration: install old and new public pins in consumers first, activate that configuration, then switch Home's signer. Keep the old public pin for at least 150 seconds after its last assertion, then remove it through configuration. A consumer missing the new pin refuses ID sign-in until updated; local sign-in remains. Remove a compromised pin immediately and revoke affected Home-derived sessions separately. There is no cache-based revocation bound. Publication/discovery requires a later design; slice 1 has no key endpoint, refresh or cached-key policy.

Sign-out, outages and gates

Capture the session’s authentication source before revocation. Every sign-out revokes locally and lands on the local signed-out page without waiting for Home. Local-authenticated sessions never redirect to Home. Only a Home-derived session may offer a separate optional Home sign-out hop from that page; this is best-effort and cannot gate local completion or local sign-in. Do not use connect.Routes.Signout's unconditional redirect unchanged. No global logout guarantee.

Home outage blocks new ID authentication/linking. Existing app sessions retain local expiry, revocation and admission checks; local sign-in and unlink continue. Failures offer deliberate retry or local sign-in without redirect loops.

Required gates: RP/origin isolation and generated WebAuthn names; address-at-rest/log scans; both sign-in paths; recovery entropy, concurrent attempt limits, replacement revocation and notice privacy; expired/replayed/swapped assertions; unmatched nonce stores no receipt; closed authorize parameters; real cross-site scriptless return; concurrent link/unlink/relink/mint; pinned rotation; and identical Equipo admission through either sign-in path. Linking must reject an otherwise valid five-minute-old proof whose auth_time precedes transaction start, and demonstrate Home re-prompts. Sign-out/outage tests use an issuer that accepts connections and hangs, proving local landing/revocation/sign-in work; refused connections alone are insufficient.

Slice 2: Contra

Paul ruled that Home mints for Contra only after passkey-backed sign-in, enforced at Home per consumer, never delegated to an assertion-strength claim. Recovery alone does not qualify. Linking is opt-in with disclosure of the new identity association; amend Contra's threat model before adoption.

Contra receives a pairwise subject: a domain-separated HMAC of person ref and immutable consumer identity under a dedicated Home key. Never send the global ref; define key rotation/migration before use. Consumers outside oficina.works need this policy in their later slice too. No domain move is required.

Move the adapter here: connect.LookupPerson expects a verified address label and integer ID, while Contra uses opaque IDs and no readable address. Preserve proof binding without inventing addresses. Oficina ID cannot supply vault keys, recover vault plaintext or bypass Contra's cryptographic proofs.

Open for slice 2: what may a locked ID-authenticated session read or do? Default to nothing beyond the unlock screen. No Contra adapter or locked-session permissions are implemented in slice 1.