001f23a2
login: the one decoder of the unified-login cookie
Six services decode sr.ht.unified-login.v1 independently, and each of them makes the same five decisions: DecryptWithoutExpiration rather than a decrypt with a service-side TTL, unmarshal into auth.AuthCookie, strip the leading '~', treat every failure as anonymity rather than an error, and validate the name before it reaches a path, a log line or a SQL parameter. Two of the six had already dropped the last one. The middleware is split into Optional and Required because that is where the copies diverged: every donor folded its own gating policy into a single middleware — never refuse (public clones), never 401 (visibility decided downstream), always send the viewer to meta's login page — so one middleware here would force most services to write the other half again. ValidName ships as the default rather than being required: the grammar is meta.sr.ht's and therefore instance-wide, and requiring a validator would put the safe path behind an extra argument that the services validating nothing today would go on not passing. WithValidator narrows it; a nil validator restores the default, so "accept anything" has no spelling in the API. Mirroring meta's profile into a service's own user row stays in each service: that touches its own schema.
Eugene Blikh <bigbes@gmail.com> — 2026-08-08 20:59:31 UTC
Commit 001f23a2bc68435fd3e9d5b7495824c6c6585072 —
view raw patch
Parent(s):
ed3a5af7
| File | Status | + | − |
|---|---|---|---|
login/login.go
|
A | +404 | |
login/login_test.go
|
A | +389 |