oficina / sheets Public

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

Plain git — no account needed to clone.

Download

Download this file

1package sheets
2
3import (
4 "net/http"
5
6 "amadan.net/rastrillo/rastrillo/auth"
7)
8
9// handleBegin is POST /signin, in both modes: auth's Begin for EVERY
10// address (with Home configured through beginSignin, which keeps the page
11// the sign-in began from).
12//
13// What the form answers depends on the address's domain, never on
14// admission. Answering "that address cannot sign in" — or answering an
15// admitted address differently from a refused one in any way — would
16// turn this endpoint into a membership oracle: anyone could enumerate
17// who is on the team by watching which addresses get a different
18// answer. So:
19//
20// - A Keymail address (a domain that runs Keymail, or delegates to it
21// with a `_keymail` TXT record), admitted or not, goes to Keymail.
22// With SigninScreen on, Begin never answers with a redirect off this
23// origin: it continues on the door (/signin?continue=), whose meta
24// refresh leaves for Keymail, because CSP's form-action 'self'
25// covers a form submission's whole redirect chain in Safari ("Refused
26// to load https://keymail.dev/oauth/authorize… form-action", Paul,
27// 2026-10-06). Admission is asked after Keymail has verified the
28// address, by auth's Authorize (App.Admits), and a refusal is the
29// door saying so (App.refused), told only to someone who has just
30// proved they hold the address.
31// - Any other address is answered ?sent=1, and mailQueue mails the
32// link only if App.Admits says yes — after the response, in a
33// worker, so not even the response time differs (mailqueue.go). Without that, anyone who
34// can reach the instance could make it email a live sign-in link to
35// any address they name — abuse of our sending identity, found by
36// POSTing a stranger's address at the deployed instance. The cost
37// is real and accepted: a member who mistypes their own address is
38// told to check their email and nothing arrives.
39//
40// Both kinds of address spend the same rate budgets and are parsed the
41// same way, so ?err=rate and ?err=address say nothing about admission
42// either; and since the send happens after the response, a failed one
43// is logged rather than answered.
44//
45// It used to gate admission in front of Begin instead, which answered a
46// non-admitted Keymail address ?sent=1 and sent an admitted one to
47// Keymail: the oracle, one level narrower.
48func (a *App) handleBegin(w http.ResponseWriter, r *http.Request) {
49 if a.returns != nil {
50 a.beginSignin(w, r)
51 return
52 }
53 a.auth.Begin(w, r)
54}
55
56// refused is auth's Refused hook: Keymail or an emailed link verified
57// the address and Admits said no. It answers with the sign-in door, the
58// refusal in the screen's app-problem slot with the email field, in a 403
59// — no session is minted, and auth has already ended the attempt and set
60// any cookies it clears.
61//
62// Rendered, not redirected to ?err=refused: a query parameter is
63// something anybody can type, and the sentence means "you proved this
64// address and it is not admitted" (Astra on oficina/slides #20, round
65// 3). Only this hook can say it, and auth calls it only after the
66// address is proved, so saying it is no membership oracle.
67func (a *App) refused(w http.ResponseWriter, r *http.Request, _ auth.Identity) {
68 a.signinDoorStatus(w, withRefusal(r), http.StatusForbidden)
69}
70