Skip to content
Toolkit

ADR-0092 — A gate refuses with a door, not a document

Status: Accepted · Date: 2026-08-29 · Track: 007 phase 02 · Supersedes nothing · Builds on: ADR-0083, ADR-0089, ADR-0090

Context

password_protection has been billed since 004 gated the write, and the password has been a bcrypt digest since ADR-0083. Nothing ever compared against that digest: redirect.go had no password branch and no unlock endpoint existed in either tree, so every gated link opened for everyone who had it.

Three questions had to be answered together, because each one's answer is only safe given the others.

Who draws the interstitial. The API could render HTML itself. It would be a second design system and a second string catalogue, both maintained in Go, against a repo rule that public surfaces are Studio primitives with their text behind t(). It would also be the first page this server renders.

What the refusal contains. A form that renders while the destination sits in the payload beside it is the defect ADR-0083 closed one layer up. The charter's bar for this point is an absence, not a form.

What the visitor brings back. A session would make an unlocked link a property of a browser and a server that remembers it. A cookie set by the API and read on a link domain is a cross-site cookie in every deployment where the app and the link live on different hosts.

Decision

A gated link refuses with a 302 to the app's interstitial, and the app is the only thing that renders. GET /l/{slug} on a link with a digest answers Location: <APP_URL>/u/{slug}?host=<the host it arrived on>. That response has no body and no destination, so the absence is a property of the shape of the answer rather than of a payload someone remembered to narrow.

A correct password buys a grant, and the grant is the only thing the visitor carries. POST /l/{slug}/unlock compares the ADR-0083 digest and answers with a signed statement — version, link id, expiry, HMAC over a domain-separated message with the deployment's secret — good for fifteen minutes and for that one link. It is not a session: the server stores nothing, so an unlock costs no row and a restart invalidates nothing. The visitor returns to /l/{slug}?grant=… on their own host, and the redirect path serves the resource exactly as it serves an ungated one — same type switch, same click record, same settings.

The grant is stripped before the destination is served. The redirect path forwards the visitor's query to the destination; the grant is a credential for this link, and forwarding it would put it in the destination's access log, its analytics, and the Referer of everything that page loads.

The gate fails closed. A handler built without a page URL or without a grant service refuses with the 404 a missing link shows. The one direction a misconfigured gate may fail is shut — which is why the gate is a constructor parameter and not a field with a usable zero value.

Every failure is the same answer. A wrong password, an unknown slug, a disabled link and an ungated one all answer 401 Incorrect password. A gate that distinguishes them is an oracle for which resources exist and which are protected. The endpoint sits behind its own instance of the login lockout's limiter — a visitor guessing a link's password must not spend the budget that protects accounts, and an attack on accounts must not be able to dress itself as gate traffic.

Consequences

  • A browser that reaches a gated link on the API host is sent to the app, which is where every other public surface of this product is already drawn.
  • The visitor's host round-trips through the interstitial (?host=, echoed by the unlock body) so a slug resolves to the same link on both halves of the door. Naming a host selects which resource is being unlocked and nothing else: the password still has to open it.
  • The unlock endpoint lives at /l/{slug}/unlock, beside the redirect, so both halves resolve the slug through one rule (requestDomainIDFor). A second resolution rule would let a slug mean one link when it is unlocked and another when it is served.
  • The client's 401 → sign out → /login interceptor now exempts /l/…, as it already exempted the auth endpoints: on this surface a 401 is the answer the visitor reads, not an expired session.
  • The biolink public payload is not gated by this decision. A gated biolink is refused at /l/{slug}, but /api/public/biolinks/{slug} — the endpoint the public page actually fetches — has its own handler and still serves blocks. The ledger row names the redirect path, which is what this slice makes true; extending the gate to that endpoint is its own slice, recorded in 007's open items rather than assumed here.
  • Sensitive content and splash pages are the same mechanism with a different reason and a different page. Neither needs a second gate.

Source: docs/decisions/0092-a-gate-refuses-with-a-door-not-a-document.md

Library