oficina / fichas Public

Sign-in: the smart door (smart-door step 6, Fichas)

Fichas adopts the smart sign-in door, as Docs, Sheets, Slides, Calendar,
Calls and Memoria did. rastrillo 96812be (v0.35.1 pseudo) to v0.43.0 and
estilo d004805 to 468fab1, together (estilo AGENTS.md). Fichas has no
Home, so email is the one way in; /signin/local and /signin/oficina 404.

- The door is rastrillo's screen, one way in (SigninScreen, SigninOneWay),
  in estilo's estilo-signin-screen; every state, the confirm step and the
  refusal included. The confirm step and the Keymail continuation are
  drawn on the one-way door, so their buttons are pills too. The
  hand-rolled confirm, continuation and error strings are gone.
- Admission probe of requireSession before /signin treats a session as
  signed in: web sessions only, any 5xx undecided, refusal (404) ends the
  session at the door, refusal on the plain door only.
- auth's Refused draws the door with Paul's approved refusal (403).
- beginGuard answers strangers with AnswerAsSent; a malformed address is
  Begin's ?err=address for anybody (no sameAnswer).
- Return memory is rastrillo's (kept on Begin, spent by every landing,
  cleared by Sign out); Fichas drops pages that are no page (/signed-out,
  the door, /auth/*) and bodies that do not parse, and clears it on Forget.
- /signed-out with "Forget me on this device"; Sign out lands there.
- Doors drawn signed out (plain layout).
- [fichas-toolbar] > [rst-seg-tabs] margin zeroed; the rail stays on
  --rst-bg; doctor --fix re-copied tokens.css, shell.css, shell.js;
  writeestilo re-wrote theme.css and chrome.css.
- CLDR 48 numbers (rastrillo v0.37): es 1234, fr 1 234 with U+202F.
- No migrations. mail.FromCarlos wiring unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 3c4758301a324a1479d556858b6f74aeab742093 parent 335ba9d
34 files changed, +2,436 −554
  • AGENTS.md +16 −0
  • cmd/fichas/main.go +1 −1
  • go.mod +3 −3
  • go.sum +6 −6
  • internal/fichas/app.go +20 −8
  • internal/fichas/auth.go +66 −16
  • internal/fichas/auth_navigation.go +0 −120
  • internal/fichas/auth_navigation_test.go +0 −122
  • internal/fichas/handlers.go +9 −125
  • internal/fichas/locale/locale_test.go +5 −5
  • internal/fichas/render.go +14 −0
  • internal/fichas/signin.go +339 −0
  • internal/fichas/signin_admission.go +158 −0
  • internal/fichas/signin_door_test.go +79 −0
  • internal/fichas/static/chrome.css +66 −4
  • internal/fichas/static/fichas.css +4 −0
  • internal/fichas/static/frame.css +4 −1
  • internal/fichas/static/shell.css +5 −3
  • internal/fichas/static/shell.js +40 −13
  • internal/fichas/static/theme.css +116 −0
  • internal/fichas/static/tokens.css +402 −6
  • internal/fichas/templates/signin.html +17 −26
  • internal/fichastest/account_test.go +1 −1
  • internal/fichastest/browser_edit_test.go +19 −11
  • internal/fichastest/browser_test.go +33 −1
  • internal/fichastest/contract_test.go +1 −1
  • internal/fichastest/signin_door_browser_test.go +162 −0
  • internal/fichastest/signin_door_helpers_test.go +189 −0
  • internal/fichastest/signin_door_refusal_test.go +174 −0
  • internal/fichastest/signin_door_return_test.go +129 −0
  • internal/fichastest/signin_door_states_test.go +255 −0
  • internal/fichastest/signin_flow_test.go +14 −12
  • internal/fichastest/signin_test.go +86 −68
  • internal/fichastest/vendored_test.go +3 −1

CI passed — run details

CI log
=== vet ===
go vet ./...
go: downloading amadan.net/rastrillo/rastrillo v0.43.0
go: downloading amadan.net/oficina/estilo.git v0.0.0-20261121233240-468fab16e803
go: downloading amadan.net/rastrillo/fiesta v1.5.0
go vet -tags browser ./internal/fichastest/
=== fmt ===
=== test ===
go test ./...
?   	amadan.net/oficina/fichas/cmd/fichas	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas	2.442s
?   	amadan.net/oficina/fichas/internal/fichas/icons	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas/locale	0.008s
ok  	amadan.net/oficina/fichas/internal/fichas/seal	0.009s
ok  	amadan.net/oficina/fichas/internal/fichastest	2.414s
?   	amadan.net/oficina/fichas/scripts/mockups	[no test files]
?   	amadan.net/oficina/fichas/scripts/preview	[no test files]
?   	amadan.net/oficina/fichas/scripts/writeestilo	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/AGENTS.md b/AGENTS.md
index 94783b3..b08b830 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -54,6 +54,22 @@ mechanically.
fights busy.js; `TestNoOldBusyRuleIsServed` reads what is served), and
`calendar.js` is left out on purpose (datetime.js falls back to the
browser's picker without it). Both are recorded in `vendoredIsMine`.
+ Doctor's Templates step still lists every template as pending and
+ refuses `card_edit`, `history`, `index` and `partials`: Fichas threads
+ its localizer as `.L` (`$L := .L`) rather than through the
+ `localizer` prelude, which doctor reads as another meaning of `$L`.
+ Leave it unwritten; the render and browser tests are the check. Run
+ doctor on the pinned toolchain (`GOTOOLCHAIN=go1.26.11`): a newer Go's
+ export data fails its type check.
+- **The sign-in door is the suite's smart door** (Home spec
+ `2026-11-19-smart-door.md`, step 6): rastrillo's screen, one way in
+ (`SigninScreen`, `SigninOneWay`), inside estilo's door (`signin.go`).
+ Fichas has no Home, so email is the one way and `/signin/local` and
+ `/signin/oficina` are 404s. The door probes `requireSession` before
+ treating a session as signed in (`signin_admission.go`), and the
+ return memory is rastrillo's with Fichas' guards (`beginReturn`).
+ Bump estilo and rastrillo together (estilo's AGENTS.md); `frame.css`
+ draws the rail on `--rst-bg`, not Calma's `--rst-rail-bg`.
## Serving
diff --git a/cmd/fichas/main.go b/cmd/fichas/main.go
index 832ff0d..4d246ef 100644
--- a/cmd/fichas/main.go
+++ b/cmd/fichas/main.go
@@ -76,7 +76,7 @@ func main() {
Origin: cfg.Origin,
InstanceKey: cfg.InstanceKey,
Mailer: mailer,
- }, logger, app.Admit)
+ }, logger, app)
if err != nil {
logger.Error("wire sign-in", "err", err)
os.Exit(1)
diff --git a/go.mod b/go.mod
index ef24d2c..96a54f2 100644
--- a/go.mod
+++ b/go.mod
@@ -5,9 +5,9 @@ go 1.26.0
toolchain go1.26.11
require (
- amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2
+ amadan.net/oficina/estilo.git v0.0.0-20261121233240-468fab16e803
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4
- amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc
+ amadan.net/rastrillo/rastrillo v0.43.0
github.com/chromedp/cdproto v0.158.6
github.com/chromedp/chromedp v0.21.0
github.com/go-chi/chi/v5 v5.3.2
@@ -19,7 +19,7 @@ require (
)
require (
- amadan.net/rastrillo/fiesta v1.3.0 // indirect
+ amadan.net/rastrillo/fiesta v1.5.0 // indirect
amadan.net/rastrillo/rastrillo/money v0.1.0 // indirect
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/carlosframework/rastrillo v0.23.0 // indirect
diff --git a/go.sum b/go.sum
index d4d2503..e540023 100644
--- a/go.sum
+++ b/go.sum
@@ -1,11 +1,11 @@
-amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2 h1:E2+IhBdGcjhX3IX8UgQj5t6Bu+4zkGG0J+W1CIeoTAo=
-amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8=
+amadan.net/oficina/estilo.git v0.0.0-20261121233240-468fab16e803 h1:yl1LyYZW3/722xRPnXMu5veg4sZGjyDMJFLqOWST0ws=
+amadan.net/oficina/estilo.git v0.0.0-20261121233240-468fab16e803/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8=
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4 h1:BP+KHZTSgL7HDCz9IL/gxKXmbmXQpclUlJIyQEY/N2E=
amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4/go.mod h1:Xgw0N+DBiDzkhQHm/nIhgumfaiMElDg/KIFD1OxTm5w=
-amadan.net/rastrillo/fiesta v1.3.0 h1:7SsHw4aeWPLStR3RHFEEtX4CwqKu+Ig3PgNX8FvD8WM=
-amadan.net/rastrillo/fiesta v1.3.0/go.mod h1:LpO391W1dIRUxOIKklHm+bGyWXtlFyBRRPQCysb9LjY=
-amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc h1:QakboVkj9nqA6ZaKXeDVXWLPobQSVvd80ic521aA8/U=
-amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc/go.mod h1:y45ucMD+Al4tN47mmnm7h6pGDw7N20k0CMg6IwB9vfc=
+amadan.net/rastrillo/fiesta v1.5.0 h1:wKfTsL5zRMofJBAqOxNlCY7aCtgHCtfwvTPBMA+ZA20=
+amadan.net/rastrillo/fiesta v1.5.0/go.mod h1:LpO391W1dIRUxOIKklHm+bGyWXtlFyBRRPQCysb9LjY=
+amadan.net/rastrillo/rastrillo v0.43.0 h1:cJWZKfJ03xqMBKTh0J5tBLmefnIU8udi1jNq7x4E7f0=
+amadan.net/rastrillo/rastrillo v0.43.0/go.mod h1:0bufVMz8D4aWvxvJjehW70T8Jsvytrp1YEwoIzFTKm8=
amadan.net/rastrillo/rastrillo/money v0.1.0 h1:MxU4oqNrW8abxRTkgZBv24OYNpFnvonajNqeLIzmmaM=
amadan.net/rastrillo/rastrillo/money v0.1.0/go.mod h1:cmgkjBEIQh1pFSYvQk0UU6oPYS8kSDypdT9+t4Flx0U=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
diff --git a/internal/fichas/app.go b/internal/fichas/app.go
index 5eef12f..ffa2f5c 100644
--- a/internal/fichas/app.go
+++ b/internal/fichas/app.go
@@ -15,6 +15,7 @@ import (
"amadan.net/rastrillo/rastrillo/db"
"amadan.net/rastrillo/rastrillo/mail"
"amadan.net/rastrillo/rastrillo/migrate"
+ "amadan.net/rastrillo/rastrillo/sessions"
"amadan.net/oficina/suite/server"
)
@@ -65,6 +66,11 @@ func App(d *db.DB, cfg Config, logger *slog.Logger) (*http.ServeMux, *app, error
}
a.owners = cfg.Owners
+ // The sessions core auth keeps its sessions in, over the same table
+ // and cookie, so the door can end a refused one (refusedSession).
+ if a.sess, err = sessions.New(sessions.Config{DB: d.Writer(), Origin: cfg.Origin, SigninPath: signinPath, Logger: logger}); err != nil {
+ return nil, nil, err
+ }
r := chi.NewRouter()
// App-wide, from day one: every state-changing route added below
@@ -78,17 +84,23 @@ func App(d *db.DB, cfg Config, logger *slog.Logger) (*http.ServeMux, *app, error
r.NotFound(notFound)
// Sign-in is outside the session guard, necessarily: it is how a
- // session is obtained. beginGuard runs before rastrillo's classifier
- // can dial a domain the visitor chose.
- r.Get(signinPath, a.signin)
- // Order matters: admission before the classifier can dial, then the
- // continuation around Begin so a keymail redirect survives the CSP.
- r.Post("/auth/begin", a.beginGuard(a.keymailContinuation(a.authBegin)))
+ // session is obtained. The door (signin.go) is rastrillo's screen in
+ // estilo's; Fichas has no Home, so there is no /signin/local or
+ // /signin/oficina, and both answer 404 like any unknown path.
+ r.Get(signinPath, a.signinRoute)
+ // Order matters: the kept page is settled first (beginReturn), then
+ // admission before the classifier can dial (beginGuard), then Begin,
+ // which with the screen on keeps a Keymail continuation on the door
+ // (?continue=) so form-action 'self' stays strict.
+ r.Post(beginPath, a.beginReturn(a.beginGuard(a.authBegin)))
r.Get("/auth/callback", a.authCallback)
// The emailed link: GET draws the confirm door, POST spends the token.
r.Get("/auth/verify", a.authVerify)
r.Post("/auth/verify", a.authVerify)
- r.Post("/signout", a.authSignout)
+ // "Use a different email", and "Forget me on this device".
+ r.Post(signinForgetPath, a.forget)
+ r.Post("/signout", a.signout)
+ r.Get(signedOutPath, a.signedOut)
// Light, dark or system: a per-person preference set by a form in the
// account menu, so it works with scripts off. estilo's handler and
// cookie; inside the CSRF check above and outside the session guard,
@@ -202,7 +214,7 @@ func AppForTest(d *db.DB, cfg Config, logger *slog.Logger, as string) (*http.Ser
Origin: cfg.Origin,
InstanceKey: cfg.InstanceKey,
Mailer: mail.Logged(logger),
- }, logger, a.Admit)
+ }, logger, a)
if err != nil {
return nil, err
}
diff --git a/internal/fichas/auth.go b/internal/fichas/auth.go
index 60cd66f..2ab3708 100644
--- a/internal/fichas/auth.go
+++ b/internal/fichas/auth.go
@@ -10,14 +10,17 @@ import (
"amadan.net/oficina/estilo.git/chrome"
"amadan.net/rastrillo/rastrillo/auth"
"amadan.net/rastrillo/rastrillo/mail"
+ "github.com/keymaildev/signin"
)
-// signinPath is where every sign-in outcome lands. It must match the
-// SigninPath given to auth.New, because beginGuard redirects here itself:
-// if the two disagree the guard becomes distinguishable from the real
-// thing by its destination alone.
+// signinPath is where every sign-in outcome lands: the door. It is the
+// SigninPath given to auth.New, so rastrillo's outcomes and the guard's
+// AnswerAsSent land in the same place.
const signinPath = "/signin"
+// beginPath is where Begin is mounted (app.go), behind beginGuard.
+const beginPath = "/auth/begin"
+
// ParseOwners splits a comma-separated allowlist, lowercasing and
// trimming.
//
@@ -78,10 +81,15 @@ func (a *app) Admit(address string) bool {
// entry and `SECURITY-DRAFT-rastrillo-signin.md` is the upstream half,
// still unfiled.
//
-// It renders the SAME outcome as a successful send — same status, same
-// destination — because a distinct rejection would turn this guard into an
-// owners-list oracle, which is worse than the dial: the dial confirms the
-// instance exists, an oracle confirms who runs it.
+// It answers a stranger with rastrillo's AnswerAsSent: Begin's own Sent,
+// down to the attempt cookie and the attempt= on the redirect, with no
+// mail. A plain ?sent=1 would lack both where an owner gets them, which
+// would turn this guard into an owners-list oracle on the first try
+// (Memoria #49) — worse than the dial: the dial confirms the instance
+// exists, an oracle confirms who runs it. It is not error hiding: it
+// answers before Begin, and Begin's own problems (a mistyped address, a
+// rate limit) reach the door as they are, for any address that gets that
+// far.
//
// **It is still an oracle after five submissions**, and memoria records
// why: this guard sits in front of rastrillo's per-address rate limiter,
@@ -89,15 +97,30 @@ func (a *app) Admit(address string) bool {
// Six tries at an owner's address yields a rate-limit error, six at a
// stranger's yields the same cheerful page every time. Closing that means
// fixing the ordering upstream, which is the same fix the dial needs.
+// Response time is the other residual: AnswerAsSent sends no mail.
func (a *app) beginGuard(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
+ if a.auth == nil {
+ a.logger.Error("no sign-in configured")
+ http.Error(w, "sign-in is not configured", http.StatusInternalServerError)
+ return
+ }
// Fail closed. An empty owners list is a wiring bug — LoadConfig
// refuses to boot without one — and the version of this that
// defaults to allowing is the version that dials for everyone
// while looking configured.
if len(a.owners) == 0 {
a.logger.Error("no owners configured; refusing sign-in")
- http.Redirect(w, r, signinPath+"?sent=1", http.StatusSeeOther)
+ a.auth.AnswerAsSent(w, r)
+ return
+ }
+ // A malformed address is Begin's to answer, as for anybody: it
+ // refuses it (?err=address, keeping force, reauth and return_to)
+ // before the classifier can dial, and an address's shape says
+ // nothing about the owners list. Answered as Sent, a typo would
+ // hide behind "check your email" (no sameAnswer: Slides #49).
+ if _, _, err := signin.SplitAddress(r.FormValue("address")); err != nil {
+ next(w, r)
return
}
// Read the address EXACTLY as rastrillo does: FormValue, not
@@ -109,7 +132,7 @@ func (a *app) beginGuard(next http.HandlerFunc) http.HandlerFunc {
if !a.Admit(r.FormValue("address")) {
// No address in the log line, ever.
a.logger.Info("sign-in refused before classifier dial")
- http.Redirect(w, r, signinPath+"?sent=1", http.StatusSeeOther)
+ a.auth.AnswerAsSent(w, r)
return
}
next(w, r)
@@ -126,11 +149,27 @@ type AuthEnv struct {
Mailer mail.Sender
}
+// Gate is what the sign-in flow needs from the app: the admission
+// predicate, and the door it draws for the two pages auth renders itself
+// (the confirm step an emailed link opens, and the refusal). Only the
+// app implements it; main passes the *app App returned.
+type Gate interface {
+ Admit(address string) bool
+ renderConfirm(w http.ResponseWriter, r *http.Request, d auth.ConfirmPageData)
+ refused(w http.ResponseWriter, r *http.Request, id auth.Identity)
+}
+
// NewAuth wires the sign-in flow. Exactly one per process: auth carries
// rate-limiter state on the value, so one per request would get a fresh
// empty budget every time and rate-limit nothing, silently.
-func NewAuth(sqlDB *sql.DB, env AuthEnv, logger *slog.Logger, authorize func(string) bool) (*auth.Auth, error) {
- if authorize == nil {
+//
+// The door is rastrillo's sign-in screen, one way in per page
+// (SigninScreen, SigninOneWay), drawn inside estilo's door (signin.go;
+// Home spec 2026-11-19-smart-door.md, step 6). Fichas has no Home, so the
+// one way is email: "Continue as {address}" for a remembered one, else
+// the field, with "Use a different email" under it.
+func NewAuth(sqlDB *sql.DB, env AuthEnv, logger *slog.Logger, gate Gate) (*auth.Auth, error) {
+ if gate == nil {
// A nil Authorize admits every verified address, which on a
// public hostname means anyone who can receive mail. Refusing
// beats defaulting: a caller that forgot to pass one has a bug
@@ -142,7 +181,7 @@ func NewAuth(sqlDB *sql.DB, env AuthEnv, logger *slog.Logger, authorize func(str
Origin: env.Origin,
InstanceKey: env.InstanceKey,
Mailer: env.Mailer,
- Authorize: authorize,
+ Authorize: gate.Admit,
SigninPath: signinPath,
SignedInPath: "/",
Subject: chrome.EmailSubject("Fichas"),
@@ -152,9 +191,20 @@ func NewAuth(sqlDB *sql.DB, env AuthEnv, logger *slog.Logger, authorize func(str
// limits and the owners list, which never mails an address it
// does not hold. rastrillo refuses to start until this is chosen.
ProofOff: true,
- // The emailed link opens the door with one Sign in button, and
- // only its POST spends the token (handlers.go, confirmSignin).
- RenderConfirm: confirmSignin,
+ // The smart door: rastrillo's screen, one way in per page. It
+ // remembers the way in (a sealed, host-only cookie), keeps the
+ // Keymail continuation on the door (?continue=), and posts to
+ // these two paths (app.go).
+ SigninScreen: true,
+ SigninOneWay: true,
+ BeginPath: beginPath,
+ ForgetPath: signinForgetPath,
+ // The emailed link opens the door's confirm step, with one Sign in
+ // button, and only its POST spends the token (signin.go).
+ RenderConfirm: gate.renderConfirm,
+ // A verified address the owners list refuses gets the door with
+ // the refusal, not rastrillo's bare-text 403.
+ Refused: gate.refused,
})
}
diff --git a/internal/fichas/auth_navigation.go b/internal/fichas/auth_navigation.go
deleted file mode 100644
index 31ac666..0000000
--- a/internal/fichas/auth_navigation.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package fichas
-
-import (
- "bytes"
- "net/http"
- "net/url"
- "strings"
-)
-
-// keymailContinuation ends the sign-in POST with a page rather than a
-// redirect when rastrillo sends the browser on to keymail.
-//
-// **The keymail CSP trap.** When the submitted address's domain delegates
-// to keymail, auth.Begin answers the form POST with a 303 to keymail's
-// /oauth/authorize. The page's CSP says `form-action 'self'`, and browsers
-// enforce form-action through a form's whole redirect chain — Safari
-// including intermediate GETs — so the navigation is refused and the button
-// spins forever. The first sign-in to the deployed app hit exactly this.
-//
-// The fix is Docs' (internal/docs/auth_navigation.go), ported rather than
-// reinvented: capture Begin's response, and if it is a 303 to a keymail
-// authorize URL that validates, end the POST with a document carrying a
-// meta refresh and a plain link. A document navigating is not the form's
-// redirect chain, so the CSP stays exactly as strict as it was — widening
-// form-action to keymail's host would have been the other fix, and a worse
-// one, because it would let any form on any page post there.
-//
-// Works with scripts off: the meta refresh needs none, and the link is the
-// fallback if a browser ignores the refresh.
-func (a *app) keymailContinuation(next http.HandlerFunc) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- result := &capturedResponse{header: make(http.Header)}
- next(result, r)
-
- destination := result.header.Get("Location")
- external := destination != "" && !strings.HasPrefix(destination, "/")
- if result.status == http.StatusSeeOther && external {
- // Refuse anything that is not exactly the URL keymail's
- // plugin builds. The destination comes from rastrillo's
- // server-side redirect and never from a submitted value,
- // but this is the one place fichas turns a URL into a link,
- // so it is also the one place an open redirect could be born.
- if !keymailDestination(destination, a.cfg.Origin) {
- a.logger.Error("sign-in redirected somewhere that is not keymail's authorize endpoint")
- http.Error(w, "sign-in could not continue", http.StatusBadGateway)
- return
- }
- // The pending cookie rastrillo set is what the callback
- // checks; drop it and the round trip fails on return.
- for _, c := range result.header.Values("Set-Cookie") {
- w.Header().Add("Set-Cookie", c)
- }
- w.Header().Set("Cache-Control", "no-store")
- // The URL carries state and a PKCE challenge. It must not
- // leak onward as a Referer.
- w.Header().Set("Referrer-Policy", "no-referrer")
- render(w, "signin", signinPage{Continue: &signinContinue{Door: doorHead(r), ContinueURL: destination}, Theme: themeAttr(r)})
- return
- }
-
- for name, values := range result.header {
- for _, v := range values {
- w.Header().Add(name, v)
- }
- }
- if result.status == 0 {
- result.status = http.StatusOK
- }
- w.WriteHeader(result.status)
- _, _ = w.Write(result.body.Bytes())
- }
-}
-
-// keymailDestination accepts only the authorize URL keymail's plugin
-// builds for THIS origin: https, no userinfo, no fragment, the exact path,
-// each required parameter present exactly once, and client_id,
-// redirect_uri, scope and the PKCE method pinned to what fichas asked for.
-// Docs' predicate, unchanged.
-func keymailDestination(destination, origin string) bool {
- u, err := url.Parse(destination)
- if err != nil || u.Scheme != "https" || u.Host == "" || u.User != nil ||
- u.Fragment != "" || u.Path != "/oauth/authorize" || u.RawPath != "" {
- return false
- }
- q, err := url.ParseQuery(u.RawQuery)
- if err != nil {
- return false
- }
- for _, key := range []string{"client_id", "redirect_uri", "scope", "code_challenge_method", "state", "code_challenge"} {
- if len(q[key]) != 1 || q.Get(key) == "" {
- return false
- }
- }
- origin = strings.TrimSuffix(origin, "/")
- return q.Get("client_id") == origin &&
- q.Get("redirect_uri") == origin+"/auth/callback" &&
- q.Get("scope") == "identify" &&
- q.Get("code_challenge_method") == "S256"
-}
-
-// capturedResponse records what a handler wrote so the wrapper can decide
-// whether to pass it through or replace it.
-type capturedResponse struct {
- header http.Header
- status int
- body bytes.Buffer
-}
-
-func (c *capturedResponse) Header() http.Header { return c.header }
-func (c *capturedResponse) WriteHeader(status int) {
- if c.status == 0 {
- c.status = status
- }
-}
-func (c *capturedResponse) Write(p []byte) (int, error) {
- if c.status == 0 {
- c.WriteHeader(http.StatusOK)
- }
- return c.body.Write(p)
-}
diff --git a/internal/fichas/auth_navigation_test.go b/internal/fichas/auth_navigation_test.go
deleted file mode 100644
index 8534056..0000000
--- a/internal/fichas/auth_navigation_test.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package fichas
-
-import (
- "html"
- "io"
- "log/slog"
- "net/http"
- "net/http/httptest"
- "net/url"
- "strings"
- "testing"
-
- "github.com/keymaildev/signin"
-)
-
-const navOrigin = "https://fichas.example.test"
-
-func navApp() *app {
- return &app{
- cfg: Config{Origin: navOrigin},
- logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
- }
-}
-
-// The trap itself: auth.Begin answers the sign-in POST with a 303 to
-// keymail, the page's CSP says form-action 'self', and the browser refuses
-// the navigation. The continuation must end the POST with a page instead,
-// leave the CSP untouched, and carry rastrillo's pending cookie through —
-// the callback fails on return without it.
-func TestKeymailContinuation(t *testing.T) {
- destination := (&signin.Keymail{Base: "https://keymail.example.test", Origin: navOrigin}).
- AuthorizeURL("state", "challenge", true)
- handler := navApp().keymailContinuation(func(w http.ResponseWriter, r *http.Request) {
- http.SetCookie(w, &http.Cookie{Name: "__Host-pending", Value: "opaque", Path: "/",
- Secure: true, HttpOnly: true, SameSite: http.SameSiteLaxMode})
- http.Redirect(w, r, destination, http.StatusSeeOther)
- })
-
- rec := httptest.NewRecorder()
- policy := "default-src 'self'; form-action 'self'"
- rec.Header().Set("Content-Security-Policy", policy)
- handler(rec, httptest.NewRequest(http.MethodPost, "/auth/begin", nil))
-
- if rec.Code != http.StatusOK || rec.Header().Get("Location") != "" {
- t.Fatalf("status=%d location=%q; the POST must end with a page, not a redirect",
- rec.Code, rec.Header().Get("Location"))
- }
- if got := rec.Header().Get("Content-Security-Policy"); got != policy {
- t.Fatalf("CSP changed to %q; widening form-action is the fix this avoids", got)
- }
- if rec.Header().Get("Cache-Control") != "no-store" || rec.Header().Get("Referrer-Policy") != "no-referrer" {
- t.Fatal("the continuation carries state and a PKCE challenge: it must not cache or leak as a Referer")
- }
-
- cookies := rec.Result().Cookies()
- if len(cookies) != 1 || cookies[0].Name != "__Host-pending" || cookies[0].Value != "opaque" ||
- !cookies[0].Secure || !cookies[0].HttpOnly || cookies[0].SameSite != http.SameSiteLaxMode {
- t.Fatalf("lost the pending cookie: %v", cookies)
- }
-
- body := html.UnescapeString(rec.Body.String())
- for _, part := range []string{
- `http-equiv="refresh"`,
- `content="0;url=` + destination + `"`,
- `href="` + destination + `"`,
- } {
- if !strings.Contains(body, part) {
- t.Fatalf("the continuation is missing %q", part)
- }
- }
- if strings.Contains(body, `action="/auth/begin"`) {
- t.Fatal("the continuation rendered another sign-in form")
- }
-}
-
-// This is the one place fichas turns a URL into a link, so it is the one
-// place an open redirect could be born. Anything that is not exactly
-// keymail's authorize URL for this origin is refused.
-func TestKeymailDestinationRefusals(t *testing.T) {
- valid := (&signin.Keymail{Base: "https://keymail.example.test", Origin: navOrigin}).
- AuthorizeURL("state", "challenge", false)
- if !keymailDestination(valid, navOrigin) {
- t.Fatalf("refused the URL keymail's own plugin builds: %s", valid)
- }
- for _, target := range []string{
- "javascript:alert(1)",
- "//keymail.example.test/oauth/authorize",
- strings.Replace(valid, "https:", "http:", 1),
- strings.Replace(valid, "keymail.example.test", "user@keymail.example.test", 1),
- valid + "#fragment",
- valid + "&state=duplicate",
- strings.Replace(valid, "/oauth/authorize", "/other", 1),
- strings.ReplaceAll(valid, url.QueryEscape(navOrigin), url.QueryEscape("https://foreign.example.test")),
- strings.Replace(valid, "S256", "plain", 1),
- } {
- if keymailDestination(target, navOrigin) {
- t.Errorf("accepted %q", target)
- }
- }
-
- rec := httptest.NewRecorder()
- navApp().keymailContinuation(func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, "https://foreign.example.test", http.StatusSeeOther)
- })(rec, httptest.NewRequest(http.MethodPost, "/auth/begin", nil))
- if rec.Code != http.StatusBadGateway || rec.Header().Get("Location") != "" {
- t.Fatalf("an off-keymail redirect: status=%d location=%q, want 502 and no Location",
- rec.Code, rec.Header().Get("Location"))
- }
-}
-
-// Every other outcome of Begin — the ?sent=1 redirect, an error page —
-// must pass through untouched, or the wrapper breaks the email path to fix
-// the keymail one.
-func TestNonKeymailOutcomesPassThrough(t *testing.T) {
- rec := httptest.NewRecorder()
- navApp().keymailContinuation(func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, "/signin?sent=1", http.StatusSeeOther)
- })(rec, httptest.NewRequest(http.MethodPost, "/auth/begin", nil))
- if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/signin?sent=1" {
- t.Fatalf("a local redirect: status=%d location=%q", rec.Code, rec.Header().Get("Location"))
- }
-}
diff --git a/internal/fichas/handlers.go b/internal/fichas/handlers.go
index 162f231..285fcdf 100644
--- a/internal/fichas/handlers.go
+++ b/internal/fichas/handlers.go
@@ -10,9 +10,9 @@ import (
"amadan.net/oficina/estilo.git/chrome"
"amadan.net/oficina/estilo.git/menu"
- "amadan.net/oficina/estilo.git/sky"
"amadan.net/rastrillo/rastrillo/auth"
"amadan.net/rastrillo/rastrillo/db"
+ "amadan.net/rastrillo/rastrillo/sessions"
"github.com/go-chi/chi/v5"
"gorm.io/gorm"
@@ -29,8 +29,12 @@ type app struct {
cfg Config
// ix is the decrypted in-memory index that search, sort and filter
// run over. It follows the event log, so no write path updates it.
- ix *Index
- auth *auth.Auth
+ ix *Index
+ auth *auth.Auth
+ // sess is the sessions core auth's sessions live in (same table, same
+ // cookie), for the one thing auth does not do on a GET: end the
+ // session of somebody the door has just refused (refusedSession).
+ sess *sessions.Sessions
owners []string
// testIdentity and allowUnauthenticated let a test act as a person
// without a magic-link round trip. **Only AppForTest sets them**, and
@@ -74,103 +78,11 @@ func (a *app) actor(r *http.Request) (Actor, error) {
// The sign-in handlers are thin because rastrillo's auth owns the flow;
// they exist so the router names methods on the app and a nil auth is
-// refused in one place rather than panicking in six.
-func (a *app) signin(w http.ResponseWriter, r *http.Request) {
- q := r.URL.Query()
- head := doorHead(r)
- if q.Get("sent") == "1" {
- // The same page for an owner and a stranger (beginGuard), so it
- // promises nothing about the address. The words are the door's.
- sent := head.Sent(signinPath)
- render(w, "signin", signinPage{Sent: &sent, Theme: themeAttr(r)})
- return
- }
- form := chrome.SignIn{
- Icon: head.Icon, App: head.App, Sky: head.Sky,
- Error: signinError(q.Get("err")),
- Action: "/auth/begin",
- }
- // rastrillo sends a failed keymail round trip back with
- // force=1&err=keymail so the page can offer plain email instead;
- // the hidden field makes the next submission skip keymail.
- if q.Get("force") == "1" {
- form.Hidden = []chrome.Hidden{{Name: "force", Value: "1"}}
- }
- render(w, "signin", signinPage{Form: &form, Theme: themeAttr(r)})
-}
-
-// signinPage is templates/signin.html's data: exactly one of its fields
-// is set. The page is the suite's door (estilo chrome) in every state —
-// the form, the check-your-email notice, the emailed link's confirm step
-// and the keymail continuation.
-type signinPage struct {
- Form *chrome.SignIn
- Sent *chrome.SignInNotice
- Confirm *signinConfirm
- Continue *signinContinue
- // Theme is <html data-theme> (themeAttr).
- Theme string
-}
-
-// Title is the tab title, the door's own for each state: "Sign in ·
-// Fichas" or "Check your email · Fichas". The keymail continuation is
-// still signing in, so it keeps the form's.
-func (p signinPage) Title() string {
- switch {
- case p.Sent != nil:
- return p.Sent.Title()
- case p.Form != nil:
- return p.Form.Title()
- case p.Confirm != nil:
- return chrome.SignIn{App: p.Confirm.Door.App}.Title()
- }
- return chrome.SignIn{App: p.Continue.Door.App}.Title()
-}
-
-// signinConfirm is the emailed link's confirm step: the door with one
-// Sign in button that POSTs the token back to /auth/verify, where
-// rastrillo spends it. The GET spends nothing, so a mail scanner that
-// fetches every link cannot sign anybody in.
-type signinConfirm struct {
- Door chrome.SignInNotice
- Heading, Submit string
- Action, Token string
-}
-
-// confirmSignin is auth.Config.RenderConfirm. rastrillo has already set
-// no-store, Referrer-Policy strict-origin (the page's URL is a live
-// credential) and the framing refusals; nothing here may loosen them.
-// The heading and the button are the door form's own "Sign in", so the
-// step reads as the door, not a new page.
-func confirmSignin(w http.ResponseWriter, r *http.Request, d auth.ConfirmPageData) {
- door := chrome.SignIn{}
- render(w, "signin", signinPage{
- Confirm: &signinConfirm{Door: doorHead(r), Heading: door.Heading(), Submit: door.Submit(), Action: d.Action, Token: d.Token},
- Theme: themeAttr(r),
- })
-}
-
-// signinContinue is the keymail continuation (auth_navigation.go): the
-// door's head, and the validated authorize URL to navigate to.
-type signinContinue struct {
- Door chrome.SignInNotice
- ContinueURL string
-}
-
-// doorHead is what every state of the door shares: Fichas' mark and name
-// at the card's head, on the suite's sky for this instance.
-func doorHead(r *http.Request) chrome.SignInNotice {
- return chrome.SignInNotice{
- Icon: assets.Path("static/brand/icon.svg"),
- App: "Fichas",
- Sky: sky.For(r.Host),
- }
-}
-
+// refused in one place rather than panicking in several. The door itself
+// is signin.go.
func (a *app) authBegin(w http.ResponseWriter, r *http.Request) { a.authOr500(w, r, authBegin) }
func (a *app) authCallback(w http.ResponseWriter, r *http.Request) { a.authOr500(w, r, authCallback) }
func (a *app) authVerify(w http.ResponseWriter, r *http.Request) { a.authOr500(w, r, authVerify) }
-func (a *app) authSignout(w http.ResponseWriter, r *http.Request) { a.authOr500(w, r, authSignout) }
type authRoute int
@@ -178,7 +90,6 @@ const (
authBegin authRoute = iota
authCallback
authVerify
- authSignout
)
func (a *app) authOr500(w http.ResponseWriter, r *http.Request, which authRoute) {
@@ -194,8 +105,6 @@ func (a *app) authOr500(w http.ResponseWriter, r *http.Request, which authRoute)
a.auth.Callback(w, r)
case authVerify:
a.auth.Verify(w, r)
- case authSignout:
- a.auth.Signout(w, r)
}
}
@@ -513,30 +422,5 @@ func (a *app) fail(w http.ResponseWriter, r *http.Request, err error) {
ErrorPage(w, r, http.StatusInternalServerError, "")
}
-// signinError turns rastrillo's ?err= codes into something a person can
-// act on. The first version showed "That did not work — try again in a
-// moment" for every code, including a missing table, which is advice that
-// can never succeed. AGENTS.md: errors in plain language.
-//
-// None of these may distinguish an admitted address from a stranger's —
-// beginGuard exists to make those look identical — so "address" means
-// malformed, never "not allowed".
-func signinError(code string) string {
- switch code {
- case "":
- return ""
- case "rate":
- return "Too many sign-in attempts for that address. Wait a few minutes, then try again."
- case "address":
- return "That doesn't look like an email address. Check it and try again."
- case "expired":
- return "That sign-in link has expired or has already been used. Ask for a new one below."
- case "keymail":
- return "Keymail couldn't finish signing you in. You can have a link emailed to you instead."
- default:
- return "Something went wrong on our side, not yours. Trying again won't help until it is fixed."
- }
-}
-
// errNotFound is a 404 for things that are not gorm rows.
var errNotFound = gorm.ErrRecordNotFound
diff --git a/internal/fichas/locale/locale_test.go b/internal/fichas/locale/locale_test.go
index a22ef4c..bc4bbf3 100644
--- a/internal/fichas/locale/locale_test.go
+++ b/internal/fichas/locale/locale_test.go
@@ -137,12 +137,12 @@ func TestDayCarriesTheYearOnlyWhenItIsNotThisOne(t *testing.T) {
}
func TestNumbersAreRastrillos(t *testing.T) {
- // fr and es are rastrillo's, not CLDR 48's: CLDR writes 1\u202f234
- // in French and 1234 in Spanish (two-digit minimum grouping).
- // Reported upstream (build note 85); these pin today's output.
+ // CLDR 48, from rastrillo v0.37.0 on (build note 85 was fixed
+ // upstream): French groups with U+202F, and Spanish leaves four
+ // digits ungrouped (two-digit minimum grouping), as browsers write.
for code, want := range map[string]string{"en-IE": "1,234",
- "en-US": "1,234", "de": "1.234", "fr": "1\u00a0234",
- "es": "1.234"} {
+ "en-US": "1,234", "de": "1.234", "fr": "1\u202f234",
+ "es": "1234"} {
if got := Get(code).Number(1234); got != want {
t.Errorf("%s writes 1234 as %q, want %q", code, got, want)
}
diff --git a/internal/fichas/render.go b/internal/fichas/render.go
index 9634c81..1d38b43 100644
--- a/internal/fichas/render.go
+++ b/internal/fichas/render.go
@@ -99,6 +99,20 @@ func render(w http.ResponseWriter, name string, data any) {
buf.WriteTo(w)
}
+// renderStatus is render with a status other than 200 (the door's 403
+// refusal): the page is rendered first, so a template error is still a
+// clean 500 rather than a 403 with half a page.
+func renderStatus(w http.ResponseWriter, name string, data any, status int) {
+ var buf bytes.Buffer
+ if err := pages[name].ExecuteTemplate(&buf, "layout", data); err != nil {
+ slog.Error("render", "page", name, "err", err)
+ http.Error(w, "something went wrong", http.StatusInternalServerError)
+ return
+ }
+ w.WriteHeader(status)
+ buf.WriteTo(w)
+}
+
// ErrorPage renders the "errors" page — templates/errors.html, which
// wraps ui's error-page partial in the layout — for status inside ref
// (rastrillo.NewRef, or empty when there is none to show). It is the
diff --git a/internal/fichas/signin.go b/internal/fichas/signin.go
new file mode 100644
index 0000000..0802638
--- /dev/null
+++ b/internal/fichas/signin.go
@@ -0,0 +1,339 @@
+package fichas
+
+// The sign-in door (Home spec 2026-11-19-smart-door.md, step 6; home
+// connect/MIGRATING.md): rastrillo's sign-in screen, its ui "signin"
+// partial fed by auth.SigninState, drawn inside estilo's door by
+// estilo-signin-screen. Its words are rastrillo's approved copy
+// (rastrillo.ui.signin_*), and the signed-out page's are estilo's
+// chrome.English, so every app in the suite says the same thing. Only the
+// refusal is Fichas' (signinRefusal).
+//
+// Fichas has no Home, so its door has one way in, email: "Continue as
+// {address}" when this browser remembers one, else the field, and under
+// it "Use a different email". /signin/local and /signin/oficina, which
+// Home-derived apps mount, are not routes here and answer 404.
+//
+// Every door is drawn signed out: the sign-in pages use the plain layout
+// (render.go), which has no account menu, even for a session the door has
+// just refused.
+
+import (
+ "bytes"
+ "context"
+ "html"
+ "net/http"
+ "net/url"
+ "strings"
+
+ "amadan.net/oficina/estilo.git/chrome"
+ "amadan.net/oficina/estilo.git/sky"
+ "amadan.net/rastrillo/rastrillo/auth"
+)
+
+// signinForgetPath is where rastrillo auth's Forget is mounted (app.go):
+// "Use a different email" on the door, and "Forget me on this device" on
+// the signed-out page. auth's own default, named here because the
+// signed-out page and auth.Config.ForgetPath must agree.
+const signinForgetPath = "/signin/forget"
+
+// signedOutPath is where Sign out lands: "You’re signed out".
+const signedOutPath = "/signed-out"
+
+// appName is the door's name for Fichas: the card's head, the partial's
+// Brand.Name ("Sign in to Fichas") and the tab title.
+const appName = "Fichas"
+
+// signinRefusal is the refusal: a verified address the owners list does
+// not hold (refused), or a session the signed-in routes no longer admit
+// (refusedSession). Drawn in the screen's app-problem slot with the email
+// field. Paul approved the wording for Docs and Sheets (2026-11-21/22):
+// the same sentence with the app's name.
+const signinRefusal = "That email can’t sign in to Fichas. Use a different email, or ask whoever runs this team to add it."
+
+// signinPage is templates/signin.html's data: exactly one of Screen and
+// SignedOut is set. Screen is rastrillo's screen in estilo's door (every
+// sign-in state, the confirm step and the refusal included); SignedOut is
+// the page Sign out lands on.
+type signinPage struct {
+ Screen *chrome.SignInScreen
+ SignedOut *chrome.SignInNotice
+ // Title is the tab title: rastrillo's for the screen's state ("Sign
+ // in to Fichas"), or estilo's "Signed out · Fichas".
+ Title string
+ // Theme is <html data-theme> (themeAttr).
+ Theme string
+}
+
+// doorIcon is Fichas' mark at the head of every door card.
+func doorIcon() string { return assets.Path("static/brand/icon.svg") }
+
+// signinRoute is GET /signin. Somebody already signed in and admitted
+// never sees the door (shared-chrome spec §9.2) unless the query names
+// one of its states, and goes to a safe return_to or "/". A session the
+// signed-in routes refuse is ended here and gets the door with the
+// refusal (refusedSession). One they cannot decide on is left alone.
+func (a *app) signinRoute(w http.ResponseWriter, r *http.Request) {
+ if a.auth == nil {
+ // Closed, as requireSession is: no sign-in is wired, so there is
+ // no door to draw.
+ a.logger.Error("no sign-in configured; refusing the door")
+ http.Error(w, "sign-in is not configured", http.StatusInternalServerError)
+ return
+ }
+ if ad := a.admission(r); ad.signedIn {
+ if !ad.admitted {
+ r = a.refusedSession(w, r)
+ } else if !signinOutcome(r) {
+ alreadySignedIn(w, r)
+ return
+ }
+ }
+ a.signinDoor(w, r, http.StatusOK)
+}
+
+// signinDoor draws the door. rastrillo decides what it shows from the
+// query and this browser's cookies (SigninState: the way in it used last,
+// Sent, problems, the Keymail continuation, the confirm step), with
+// SigninOneWay drawing one way in per page. Fichas adds the refusal, which
+// only someone who has just verified the address, or whose session the
+// signed-in routes no longer admit, reaches.
+func (a *app) signinDoor(w http.ResponseWriter, r *http.Request, status int) {
+ st := a.auth.SigninState(r)
+ if st.Unavailable {
+ // Under a base path or on a direct host the hub signs people in,
+ // and every route rastrillo's door names answers 404 there. So
+ // does the door.
+ notFound(w, r)
+ return
+ }
+ // The confirm step and the Keymail continuation are drawn before
+ // SigninState reads SigninOneWay, so the partial drew them as the
+ // classic door: a square Sign in among the one-way door's pills (the
+ // estilo review's note that Fichas' confirm form had no pill). Marked
+ // one-way, they are the same markup on the one-way door, whose
+ // buttons are Fiesta's pills; neither draws a Forget either way.
+ if st.Step == auth.StepConfirm || st.Step == auth.StepContinue {
+ st.OneWay = true
+ }
+ if refusedHere(r) {
+ st.AppProblem = &auth.AppProblem{Text: signinRefusal, Ask: true}
+ }
+ // The door's forms post this, and the chooser's links carry it: a
+ // page that is no page to come back to is dropped here as well as at
+ // Begin (beginReturn).
+ if !keepableReturn(st.ReturnTo) {
+ st.ReturnTo = ""
+ }
+ a.auth.PrepareSigninResponse(w, st)
+ screen := chrome.SignInScreen{Icon: doorIcon(), App: appName, Sky: sky.For(r.Host), State: st, L: a.readerL(r)}
+ title, err := signinTitle(screen)
+ if err != nil {
+ a.logger.Error("fichas: render the sign-in title", "err", err)
+ ErrorPage(w, r, http.StatusInternalServerError, "")
+ return
+ }
+ w.Header().Set("Cache-Control", "no-store")
+ renderStatus(w, "signin", signinPage{Screen: &screen, Title: title, Theme: themeAttr(r)}, status)
+}
+
+// signinTitle is the door's <title>: estilo's estilo-signin-screen-title,
+// which is rastrillo's signin-title for the same state, so the tab and
+// the heading always say the same thing ("Sign in to Fichas", "Check your
+// email to sign in to Fichas"). The template writes escaped text and the
+// layout escapes the title again, so it is unescaped here.
+func signinTitle(screen chrome.SignInScreen) (string, error) {
+ var b bytes.Buffer
+ if err := pages["signin"].ExecuteTemplate(&b, "estilo-signin-screen-title", screen); err != nil {
+ return "", err
+ }
+ return strings.TrimSpace(html.UnescapeString(b.String())), nil
+}
+
+// renderConfirm is auth's RenderConfirm, the page an emailed link opens on
+// (GET /auth/verify): the door, whose SigninState answers StepConfirm on
+// this request alone, with one Sign in button that POSTs the token back,
+// where auth spends it. The GET spends nothing, so a mail-security scanner
+// that fetches every link cannot sign anybody in. auth has already set
+// no-store, Referrer-Policy strict-origin (the URL is a live credential)
+// and the framing refusals; nothing here loosens them.
+func (a *app) renderConfirm(w http.ResponseWriter, r *http.Request, _ auth.ConfirmPageData) {
+ a.signinDoor(w, r, http.StatusOK)
+}
+
+// refused is auth's Refused hook: Keymail or an emailed link verified the
+// address and the owners list said no. It answers with the door, carrying
+// the refusal, in a 403: no session is minted, and auth has already ended
+// the attempt and spent the kept page.
+//
+// Drawn in this response, never from a query parameter: those are
+// something anybody can type, and the sentence means "you proved this
+// address and it is not admitted". Only this hook can say it, and auth
+// calls it only after the address is proved, so saying it is no
+// owners-list oracle; beginGuard's sameness is about the unproved submit,
+// and is untouched.
+func (a *app) refused(w http.ResponseWriter, r *http.Request, _ auth.Identity) {
+ a.signinDoor(w, withRefusal(r), http.StatusForbidden)
+}
+
+// refusedKey marks a request the door draws with the refusal.
+type refusedKey struct{}
+
+// withRefusal marks r as a refusal the door draws.
+//
+// Only on the plain door: the chooser (?ways=) and a way's own page
+// (?way=) are how a refused person reaches another way in, and a refusal
+// there would draw the field again over them (Fable on Docs #139, N1).
+// Fichas has only email, so nothing links there, but a typed URL is drawn
+// as asked.
+func withRefusal(r *http.Request) *http.Request {
+ if choosing(r) {
+ return r
+ }
+ return r.WithContext(context.WithValue(r.Context(), refusedKey{}, true))
+}
+
+// choosing reports whether r is the chooser or a way's own page.
+func choosing(r *http.Request) bool {
+ q := r.URL.Query()
+ return q.Has("ways") || q.Has("way")
+}
+
+// refusedHere reports whether r is a refusal the door is drawing. Never
+// from the query.
+func refusedHere(r *http.Request) bool {
+ v, _ := r.Context().Value(refusedKey{}).(bool)
+ return v
+}
+
+// signedOut serves GET /signed-out, where Sign out lands, in the door's
+// words: "You’re signed out", Sign in, then the quiet "Forget me on this
+// device" (the smart-door spec's "Signed out"), a POST to rastrillo auth's
+// Forget for a shared computer. Fichas has no Home, so there is no Oficina
+// ID to go on and forget too: the chain to id.* is a Home-derived app's.
+func (a *app) signedOut(w http.ResponseWriter, r *http.Request) {
+ out := chrome.SignInNotice{Icon: doorIcon(), App: appName, Sky: sky.For(r.Host)}.
+ SignedOut(signinPath).Forgetting(signinForgetPath, "")
+ w.Header().Set("Cache-Control", "no-store")
+ renderStatus(w, "signin", signinPage{SignedOut: &out, Title: out.Title(), Theme: themeAttr(r)}, http.StatusOK)
+}
+
+// forget is POST /signin/forget, rastrillo auth's Forget: "Use a
+// different email" on the door, and "Forget me on this device" on the
+// signed-out page. It also forgets a page a sign-in in progress kept: the
+// door that sent the post carries its own return_to, and on a shared
+// computer the kept page is the last person's, not the next one's.
+func (a *app) forget(w http.ResponseWriter, r *http.Request) {
+ if a.auth == nil {
+ http.Error(w, "sign-in is not configured", http.StatusInternalServerError)
+ return
+ }
+ if r.Method == http.MethodPost {
+ a.forgetReturn(w, r)
+ }
+ a.auth.Forget(w, r)
+}
+
+// signout is POST /signout: rastrillo's Sign out (which ends the session
+// and forgets a kept page itself), landing on /signed-out rather than on
+// the bare door, which, with no word about what just happened, read like
+// an error (memoria's polish audit §B5).
+func (a *app) signout(w http.ResponseWriter, r *http.Request) {
+ if a.auth == nil {
+ http.Error(w, "sign-in is not configured", http.StatusInternalServerError)
+ return
+ }
+ a.auth.Signout(&rewriteLocation{ResponseWriter: w, from: signinPath, to: signedOutPath}, r)
+}
+
+// rewriteLocation swaps one Location for another at the last moment a
+// header is still settable.
+type rewriteLocation struct {
+ http.ResponseWriter
+ from, to string
+}
+
+func (rw *rewriteLocation) WriteHeader(status int) {
+ if rw.Header().Get("Location") == rw.from {
+ rw.Header().Set("Location", rw.to)
+ }
+ rw.ResponseWriter.WriteHeader(status)
+}
+
+func (rw *rewriteLocation) Write(b []byte) (int, error) { return rw.ResponseWriter.Write(b) }
+
+// The return memory (shared-chrome spec §9.4) is rastrillo's own: a
+// signed-out page request goes to /signin?return_to=<the page>, the door
+// posts it to Begin, and Begin keeps it in a host-only cookie across the
+// mail or Keymail round trip. Its protections, which Docs', Sheets',
+// Slides', Calendar's, Calls' and Memoria's reviews asked of each app's
+// own, are rastrillo's here, and Fichas adds the rest:
+//
+// - a post without return_to forgets the kept page (rastrillo's
+// keepReturnTo, AnswerAsSent included, so owner and stranger alike);
+// - every landing that mints a session spends it, admitted or not
+// (rastrillo's admit: the emailed link's POST and the Keymail
+// callback, the only two ways Fichas mints a session);
+// - Sign out clears it (rastrillo's Signout), and so does Forget
+// (forget, above);
+// - a body that does not parse, or a page that is no page to come back
+// to (/signed-out, the door, auth's own routes), keeps nothing
+// (beginReturn);
+// - there is no /signin/local to overwrite it.
+
+// beginReturn is POST /auth/begin, outermost: Begin keeps no page it
+// should not. A body that fails to parse keeps none at all: Go leaves
+// what it parsed before the error in the form, and rastrillo would read
+// a return_to from it. A return_to that is no page to come back to
+// (keepableReturn) is taken off the form, so Begin forgets the kept page
+// instead and the landing is "/".
+func (a *app) beginReturn(next http.HandlerFunc) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ parsed := r.ParseForm() == nil
+ if v := r.PostForm["return_to"]; !parsed || len(v) != 1 || !keepableReturn(v[0]) {
+ if r.PostForm != nil {
+ r.PostForm.Del("return_to")
+ }
+ if r.Form != nil {
+ r.Form.Del("return_to")
+ }
+ }
+ next(w, r)
+ }
+}
+
+// keepableReturn reports whether a return_to names a page a fresh
+// sign-in may land on: a same-origin path, and not the signed-out page
+// ("You’re signed out" straight after signing in), the door, or auth's
+// own routes, with or without a query.
+func keepableReturn(to string) bool {
+ if to == "" || !strings.HasPrefix(to, "/") || strings.HasPrefix(to, "//") || strings.HasPrefix(to, "/\\") {
+ return false
+ }
+ u, err := url.Parse(to)
+ if err != nil || u.Scheme != "" || u.Host != "" {
+ return false
+ }
+ p := u.Path
+ return p != signedOutPath && p != signinPath && !strings.HasPrefix(p, signinPath+"/") && !strings.HasPrefix(p, "/auth/")
+}
+
+// returnCookieName is rastrillo auth's kept-page cookie: rastrillo_return_to,
+// __Host- prefixed on an https origin, as auth names its cookies.
+func (a *app) returnCookieName() string {
+ if strings.HasPrefix(a.cfg.Origin, "https://") {
+ return "__Host-rastrillo_return_to"
+ }
+ return "rastrillo_return_to"
+}
+
+// forgetReturn clears the kept page, if this browser holds one.
+func (a *app) forgetReturn(w http.ResponseWriter, r *http.Request) {
+ name := a.returnCookieName()
+ if _, err := r.Cookie(name); err != nil {
+ return
+ }
+ http.SetCookie(w, &http.Cookie{
+ Name: name, Value: "", Path: "/", MaxAge: -1, HttpOnly: true,
+ Secure: strings.HasPrefix(a.cfg.Origin, "https://"), SameSite: http.SameSiteLaxMode,
+ })
+}
diff --git a/internal/fichas/signin_admission.go b/internal/fichas/signin_admission.go
new file mode 100644
index 0000000..f357213
--- /dev/null
+++ b/internal/fichas/signin_admission.go
@@ -0,0 +1,158 @@
+package fichas
+
+// The door's admission check (home connect/MIGRATING.md, step 6, item 2):
+// before /signin may treat a live session as signed in, the gate every
+// signed-in page runs (requireSession) is asked about it, on a probe. A
+// session it refuses is ended at the door and gets the door with the
+// refusal; one it cannot decide on is left alone. Without it, a session
+// whose address was taken off FICHAS_OWNERS would go round /signin, the
+// page's 404 and back.
+//
+// What the door judges, and what it never touches: a web sign-in (an
+// emailed link or Keymail, the two ways Fichas mints a session) is judged.
+// Any other session is never judged, refused or ended here: the door is
+// drawn for it as for anybody signed out. Fichas has no other kind today;
+// the rule is the suite's (Calendar #48), so one added later is not
+// signed out by a door that cannot speak for it.
+
+import (
+ "bytes"
+ "net/http"
+ "net/url"
+
+ "amadan.net/rastrillo/rastrillo/sessions"
+ "github.com/keymaildev/signin"
+)
+
+// admissionResult is what the probe found: whether r holds a web sign-in
+// at all, and whether the signed-in routes let it in.
+type admissionResult struct {
+ signedIn, admitted bool
+}
+
+// admission runs the gate every signed-in page runs (requireSession:
+// rastrillo auth's RequireSession, then the owners list) around a probe
+// GET / whose answer is thrown away. A session is not enough: one for an
+// address taken off the owners list is still valid. The probe ends
+// nothing itself; the door does, for a session it decides to refuse.
+func (a *app) admission(r *http.Request) admissionResult {
+ if a.allowUnauthenticated {
+ // AppForTest: the stub identity is signed in and admitted, as
+ // requireSession says.
+ return admissionResult{signedIn: a.testIdentity != "", admitted: a.testIdentity != ""}
+ }
+ if a.auth == nil {
+ return admissionResult{}
+ }
+ id, ok := a.auth.SessionFrom(r)
+ if !ok || !doorJudges(signin.Method(id.Method)) {
+ // Signed out, a session store that could not be read (rastrillo
+ // logs it and keeps the cookie), or a session that is not a web
+ // sign-in: the door is drawn, and nothing is refused or ended.
+ return admissionResult{}
+ }
+ probe := r.Clone(r.Context())
+ probe.Method = http.MethodGet
+ probe.URL = &url.URL{Path: "/"}
+ probe.RequestURI = "/"
+ probe.Body = http.NoBody
+ reached := false
+ rec := &capturedResponse{header: make(http.Header)}
+ a.requireSession(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { reached = true })).ServeHTTP(rec, probe)
+ return probeVerdict(reached, rec.status)
+}
+
+// probeVerdict reads the probe's answer. The gate let the request through:
+// admitted. It refused it as a page that is not there (404, requireSession's
+// refusal): refused. It could not decide (any 5xx): undecided, which counts
+// as admitted, because the door must not tell somebody they cannot sign
+// in, nor sign them out, because something failed; the page they go on to
+// says so. Anything else (the session gone between the two reads, sent
+// back to the door): signed out, nothing refused or ended.
+func probeVerdict(reached bool, status int) admissionResult {
+ switch {
+ case reached:
+ return admissionResult{signedIn: true, admitted: true}
+ case status >= http.StatusInternalServerError:
+ return admissionResult{signedIn: true, admitted: true}
+ case status == http.StatusNotFound:
+ return admissionResult{signedIn: true}
+ }
+ return admissionResult{}
+}
+
+// doorJudges reports whether the door's probe judges a session by method:
+// the two web sign-ins requireSession speaks for.
+func doorJudges(method signin.Method) bool {
+ return method == signin.MethodMagicLink || method == signin.MethodKeymail
+}
+
+// refusedSession answers for a session the probe refused: it is ended and
+// its cookie cleared on this response, so a reload is plainly signed out
+// rather than a dead cookie over the plain door, and the door is marked
+// to say why. Removal happens HERE, at the door, never inside the probe.
+// The remembered email way is kept: offered again, it is no loop, because
+// Begin's own refusal answers it.
+func (a *app) refusedSession(w http.ResponseWriter, r *http.Request) *http.Request {
+ if a.sess != nil {
+ a.sess.SignOut(w, r)
+ }
+ w.Header().Set("Cache-Control", "no-store")
+ return withRefusal(withoutCookie(r, a.auth.SessionCookie()))
+}
+
+// withoutCookie is r, as seen by a handler that must not see the named
+// cookie: the door drawn after a refused session's end.
+func withoutCookie(r *http.Request, name string) *http.Request {
+ c := r.Clone(r.Context())
+ c.Header.Del("Cookie")
+ for _, cookie := range r.Cookies() {
+ if cookie.Name != name {
+ c.AddCookie(cookie)
+ }
+ }
+ return c
+}
+
+// signinOutcome reports whether GET /signin names a state of the door
+// rather than opening it afresh: an outcome of the email flow (?sent,
+// ?err, ?force), the Keymail continuation (?continue) or a step-up
+// (?reauth). Those are drawn for a signed-in browser too.
+func signinOutcome(r *http.Request) bool {
+ q := r.URL.Query()
+ return q.Has("sent") || q.Has("err") || q.Has("force") || q.Has("continue") || q.Has("reauth")
+}
+
+// alreadySignedIn sends a signed-in GET /signin back where it came from,
+// with no door: 303 to a safe return_to, or "/".
+func alreadySignedIn(w http.ResponseWriter, r *http.Request) {
+ target := "/"
+ if q, err := url.ParseQuery(r.URL.RawQuery); err == nil && len(q["return_to"]) == 1 {
+ if to := sessions.SafeReturnTo(q.Get("return_to"), ""); to != "" && keepableReturn(to) {
+ target = to
+ }
+ }
+ w.Header().Set("Cache-Control", "no-store")
+ http.Redirect(w, r, target, http.StatusSeeOther)
+}
+
+// capturedResponse records what a handler wrote, so the probe can read
+// the gate's answer without sending it.
+type capturedResponse struct {
+ header http.Header
+ status int
+ body bytes.Buffer
+}
+
+func (c *capturedResponse) Header() http.Header { return c.header }
+func (c *capturedResponse) WriteHeader(status int) {
+ if c.status == 0 {
+ c.status = status
+ }
+}
+func (c *capturedResponse) Write(p []byte) (int, error) {
+ if c.status == 0 {
+ c.WriteHeader(http.StatusOK)
+ }
+ return c.body.Write(p)
+}
diff --git a/internal/fichas/signin_door_test.go b/internal/fichas/signin_door_test.go
new file mode 100644
index 0000000..d8ef69f
--- /dev/null
+++ b/internal/fichas/signin_door_test.go
@@ -0,0 +1,79 @@
+package fichas
+
+import (
+ "net/http"
+ "testing"
+
+ "github.com/keymaildev/signin"
+)
+
+// The probe's verdicts. Any 5xx is undecided, which the door treats as
+// admitted: it never shows the refusal or ends a session because
+// something failed. Only the gate's own refusal (404) is a refusal.
+// Fichas' gate reads no store of its own (the owners list is config), so
+// this is the rule a future store read inherits, pinned here.
+func TestTheProbesVerdicts(t *testing.T) {
+ for _, c := range []struct {
+ reached bool
+ status int
+ signedIn, admitted bool
+ }{
+ {true, 0, true, true},
+ {false, http.StatusInternalServerError, true, true},
+ {false, http.StatusServiceUnavailable, true, true},
+ {false, http.StatusBadGateway, true, true},
+ {false, http.StatusNotFound, true, false},
+ {false, http.StatusSeeOther, false, false},
+ {false, http.StatusForbidden, false, false},
+ } {
+ got := probeVerdict(c.reached, c.status)
+ if got.signedIn != c.signedIn || got.admitted != c.admitted {
+ t.Errorf("reached %v, status %d: %+v, want signedIn %v admitted %v", c.reached, c.status, got, c.signedIn, c.admitted)
+ }
+ }
+}
+
+// The door judges the two web sign-ins and nothing else.
+func TestTheDoorJudgesOnlyWebSignins(t *testing.T) {
+ for method, want := range map[signin.Method]bool{
+ signin.MethodMagicLink: true,
+ signin.MethodKeymail: true,
+ "home-assertion": false,
+ "home-assertion-native": false,
+ "passkey": false,
+ "": false,
+ } {
+ if got := doorJudges(method); got != want {
+ t.Errorf("doorJudges(%q) = %v, want %v", method, got, want)
+ }
+ }
+}
+
+// What a fresh sign-in may land on.
+func TestKeepableReturn(t *testing.T) {
+ for to, want := range map[string]bool{
+ "/": true,
+ "/cards/new": true,
+ "/t/abc?sort=name": true,
+ "": false,
+ "cards": false,
+ "//evil.example/": false,
+ "/\\evil.example": false,
+ "https://evil.ex/": false,
+ "/signed-out": false,
+ "/signed-out?x=1": false,
+ "/signin": false,
+ "/signin?ways=1": false,
+ "/signin/forget": false,
+ "/auth/verify": false,
+ "/signed-outward": true,
+ "/signinsheet": true,
+ "/authors": true,
+ "/%zz": false,
+ "javascript:alert1": false,
+ } {
+ if got := keepableReturn(to); got != want {
+ t.Errorf("keepableReturn(%q) = %v, want %v", to, got, want)
+ }
+ }
+}
diff --git a/internal/fichas/static/chrome.css b/internal/fichas/static/chrome.css
index 92d0fd4..83a482f 100644
--- a/internal/fichas/static/chrome.css
+++ b/internal/fichas/static/chrome.css
@@ -290,15 +290,77 @@
[estilo-door] { padding-inline: 14px; padding-block-start: 28px; }
[estilo-signin] { padding: 26px 22px 24px; }
}
-[estilo-signin-foot] { margin-block-start: var(--rst-sp-6); font-size: var(--rst-fs-xs); color: var(--rst-text-muted); }
/* The door's links are drawn here, not left to the app: an app that does
not link base.css (Calendar, Memoria, Calls, Fichas) showed the browser's
blue on the card. As base.css does, a link in the card is the app's
colour at the lowest specificity, so a link drawn as a button keeps the
- button's; the foot's is quiet, like its text. */
+ button's. The card has no footer links (Paul, 2026-11-19). */
:where([estilo-signin]) a { color: var(--rst-accent); text-underline-offset: 0.15em; }
-[estilo-signin-foot] a { color: inherit; }
-[estilo-signin-foot] a:hover, [estilo-signin-foot] a:focus-visible { color: var(--rst-text); }
+/* The smart door (estilo-signin-screen): rastrillo's sign-in partial in
+ the card, inside [estilo-signin-screen]. The partial is a card of its
+ own, made for the stage shell, with its brand in a column beside the
+ way in; here the door is the card and its head is the brand, so the
+ partial's surface, edge, padding and columns go, and so does its brand
+ (the one brand on the card is the door's). Its buttons, rows and quiet
+ controls are rastrillo's own. The partial is reached by structure, not
+ by its rst- names, which are rastrillo's to style (AGENTS.md,
+ Vocabulary): its card is a <section> of two children, the brand column
+ then the door. The brand is hidden only while there are two, and never
+ a child holding the heading, so a partial that draws no brand
+ (HideBrand) keeps its door. Delete the hiding rule in the rastrillo
+ bump that adopts HideBrand. The heading restates the door's own size
+ one step more specific than rastrillo's door heading, so the order the
+ stylesheets are linked in never decides it. */
+[estilo-signin-screen] > section { display: block; inline-size: auto; max-inline-size: none; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
+[estilo-signin-screen] > section > :first-child:not(:only-child):not(:has(h1)) { display: none; }
+[estilo-signin] [estilo-signin-screen] h1 { margin: 0 0 2px; font-size: 1.75rem; font-weight: 620; letter-spacing: -0.02em; line-height: 1.15; }
+/* The door's buttons are the smart door's (Paul, 2026-11-21, "yes to pill
+ buttons"), on every card the door draws. The card's main action is a
+ full-width pill, 44px tall, lit from above, its shadow tinted by its
+ fill: the accent's, or red for a danger button. Its secondary controls
+ are quiet text buttons, centred under it: medium weight, the muted ink
+ that darkens over a soft pill on hover and focus, a touch smaller than
+ body text. rastrillo's one-way door already draws its own buttons this
+ way; nothing here reaches it.
+
+ Keyed on estilo's hooks, never on rastrillo's button attributes, which
+ are rastrillo's to style (AGENTS.md, Vocabulary; internal/lint):
+ - a door sign-in form's submit ([estilo-signin-form]) is its main
+ action, so the classic form and every app's confirm step are pills;
+ - [estilo-signin-action] marks any other main action on the card, and
+ [estilo-signin-action~="danger"] a destructive one;
+ - [estilo-signin-action~="quiet"] marks a secondary control, as the
+ signed-out page's Forget ([estilo-signin-forget]) is.
+ The button keeps its rastrillo variant for its fill and states; these
+ rules give it the door's shape. A hidden button stays hidden. */
+[estilo-signin] :is([estilo-signin-form] [type="submit"], [estilo-signin-action]:not([estilo-signin-action~="quiet"])):not([hidden]) {
+ display: flex; inline-size: 100%; box-sizing: border-box; justify-content: center; align-items: center;
+ min-block-size: 44px; padding-inline: 18px; border-radius: 999px; font-weight: 600; text-decoration: none;
+}
+/* The glow lifts the pill only at rest: pressed, rastrillo's own pressed
+ shadow draws it sinking. */
+[estilo-signin] :is([estilo-signin-form] [type="submit"], [estilo-signin-action]:not([estilo-signin-action~="quiet"])):not([hidden]):not(:active) {
+ box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.22), 0 1px 1px rgb(23 32 60 / 0.10),
+ 0 8px 18px -8px var(--estilo-signin-glow, light-dark(color-mix(in srgb, var(--rst-accent-fill, var(--rst-accent)) 80%, transparent), color-mix(in srgb, var(--rst-accent-fill, var(--rst-accent)) 30%, transparent)));
+}
+[estilo-signin] [estilo-signin-action~="danger"] {
+ --estilo-signin-glow: light-dark(color-mix(in srgb, var(--rst-danger-fill, var(--rst-tone-negative-fg)) 60%, transparent), color-mix(in srgb, var(--rst-danger-fill, var(--rst-tone-negative-fg)) 30%, transparent));
+}
+[estilo-signin-forget] { margin: var(--rst-sp-2) 0 0; }
+[estilo-signin] :is([estilo-signin-action~="quiet"], [estilo-signin-forget] > button):not([hidden]) {
+ display: flex; inline-size: fit-content; margin-inline: auto; justify-content: center; align-items: center;
+ min-block-size: 2.5rem; padding: 0 0.875rem; border-color: transparent; border-radius: 999px; background: transparent; box-shadow: none;
+ color: var(--rst-text-muted); font-size: calc(var(--rst-fs-base) * 0.9375); font-weight: 500; text-decoration: none;
+}
+/* On touch, and on a narrow screen, a quiet control is a full tap target,
+ as rastrillo's door draws its ghost (max(2.5rem, --rst-target), which is
+ 2.75rem there). Restated rather than read: estilo's pinned rastrillo
+ does not declare --rst-target, and every token chrome.css reads must be
+ declared by the pin (TestChromeUsesDefinedTokens). */
+@media (pointer: coarse), (max-width: 40rem) {
+ [estilo-signin] :is([estilo-signin-action~="quiet"], [estilo-signin-forget] > button):not([hidden]) { min-block-size: 2.75rem; }
+}
+[estilo-signin] :is([estilo-signin-action~="quiet"], [estilo-signin-forget] > button):is(:hover, :focus-visible) { background: var(--rst-ghost-face-hover, var(--rst-surface-2)); color: var(--rst-text); }
/* ── Bar stack (Docs' I2 editor header, spec 2026-11-11) ────────────────
Everything below is opt-in. Each rule is keyed on a hook only a bar
diff --git a/internal/fichas/static/fichas.css b/internal/fichas/static/fichas.css
index 33e1c21..bffb682 100644
--- a/internal/fichas/static/fichas.css
+++ b/internal/fichas/static/fichas.css
@@ -118,6 +118,10 @@
gap: var(--rst-sp-3);
margin-block-end: var(--rst-sp-4);
}
+/* The view switch sits in the row, so rastrillo's margin under a block of
+ tabs (since v0.35, kept by v0.42) only pushes the row apart and lifts
+ the tabs off its centre line: Calendar's 18px toolbar gap (#48). */
+[fichas-toolbar] > [rst-seg-tabs] { margin-block: 0; }
/* ---- Show view: the record's story beside its facts. */
[fichas-split] {
diff --git a/internal/fichas/static/frame.css b/internal/fichas/static/frame.css
index ac53187..49aed31 100644
--- a/internal/fichas/static/frame.css
+++ b/internal/fichas/static/frame.css
@@ -38,7 +38,10 @@
gap: 2px;
padding: 12px 8px;
border-inline-end: 1px solid var(--rst-line);
- background: var(--rst-rail-bg, var(--rst-bg));
+ /* The page's own ground, not --rst-rail-bg: Calma declares that as
+ --rst-surface since estilo 487cadb, which would tint the rail
+ (estilo AGENTS.md, "bump estilo and rastrillo together"). */
+ background: var(--rst-bg);
overflow-y: auto;
box-sizing: border-box;
}
diff --git a/internal/fichas/static/shell.css b/internal/fichas/static/shell.css
index b149ec3..b6f3169 100644
--- a/internal/fichas/static/shell.css
+++ b/internal/fichas/static/shell.css
@@ -1,11 +1,13 @@
/* shell.css — the slide between the index and a page on a phone, for
- the sidebar and console shells, the only layouts that link it.
+ the sidebar, console and one-row topbar shells (the topbar's index
+ is /menu), the only layouts that link it.
It is a file of its own because the opt-in cannot be scoped: written
in tokens.css, @view-transition would opt every page of every shell
into cross-document transitions at narrow widths, the sign-in page
- included. Both documents must opt in, and a stylesheet only these two
- shells link is exactly that set. Delete it (and its <link>) and
+ included. Both documents must opt in, and a stylesheet only these
+ three shells link is exactly that set. A 1.3 topbar layout does not
+ link it, and keeps navigating without a slide. Delete it (and its <link>) and
navigation is instant; nothing else changes.
shell.js types each transition "forward" or "back" in pagereveal.
diff --git a/internal/fichas/static/shell.js b/internal/fichas/static/shell.js
index 72cde24..b8976cc 100644
--- a/internal/fichas/static/shell.js
+++ b/internal/fichas/static/shell.js
@@ -5,16 +5,16 @@
app-owned from the moment it is scaffolded.
What it reads, all written by the layouts, in either spelling:
- [rst-shell-sidebar~="index"|"page"], [rst-shell-console~=…]
- which view the server rendered (the "view"
+ [rst-shell-sidebar~="index"|"page"], [rst-shell-console~=…],
+ [rst-shell-topbar~=…] which view the server rendered (the "view"
block): .rst-shell-sidebar--index and so on
- [rst-shell-back] > a the back control, the strip's own link; its
- href is the "up" block. Only the direct child:
- a page may put a menu in the strip too, and
- its links are not a way back
+ [rst-shell-back] > a the back control: the strip's own link, not
+ one in a menu also in the strip
+ [rst-shell-up] the back control in a one-row shell's bar
+ (each one's href is the "up" block)
[rst-shell-nav] a the index's rows
- What it adds, three things:
+ What it adds, four things:
1. Direction. In pagereveal it types the view transition "back" or
"forward", which shell.css turns into a slide.
2. Back reuses history. A plain click on the back control calls
@@ -25,17 +25,22 @@
records its path in sessionStorage; revealing the index at phone
width focuses the nav link to that path, or else the one the URL's
#fragment names.
+ 4. A name that does not fit. In a one-row shell's phone row (the
+ title or brand after [rst-shell-up], or in the rail of a sidebar
+ holding one) tokens.css cuts a name too wide for the row with an
+ ellipsis; this marks it hidden, so a name shows whole or not at
+ all, and measures it again on a resize.
- Sidebar and console use defer blocking="render" for focus and
- direction after parsing. Other layouts use transition.js before
+ Sidebar, console and the one-row topbar (whose index is /menu) use
+ defer blocking="render" for focus and direction after parsing. Other layouts use transition.js before
styles so incoming transitions skipped before pagereveal are observed. */
(function () {
"use strict";
- var ROOT = "[rst-shell-sidebar],[rst-shell-console],.rst-shell-sidebar,.rst-shell-console";
- var INDEX = '[rst-shell-sidebar~="index"],[rst-shell-console~="index"],.rst-shell-sidebar--index,.rst-shell-console--index';
- var PAGE = '[rst-shell-sidebar~="page"],[rst-shell-console~="page"],.rst-shell-sidebar--page,.rst-shell-console--page';
- var BACK = "[rst-shell-back] > a[href],.rst-shell__back > a[href]";
+ var ROOT = "[rst-shell-sidebar],[rst-shell-console],[rst-shell-topbar],.rst-shell-sidebar,.rst-shell-console,.rst-shell-topbar";
+ var INDEX = '[rst-shell-sidebar~="index"],[rst-shell-console~="index"],[rst-shell-topbar~="index"],.rst-shell-sidebar--index,.rst-shell-console--index,.rst-shell-topbar--index';
+ var PAGE = '[rst-shell-sidebar~="page"],[rst-shell-console~="page"],[rst-shell-topbar~="page"],.rst-shell-sidebar--page,.rst-shell-console--page,.rst-shell-topbar--page';
+ var BACK = "[rst-shell-back] > a[href],.rst-shell__back > a[href],[rst-shell-up][href],.rst-shell__up[href]";
var NAV = "[rst-shell-nav] a[href],.rst-shell__nav a[href]";
var NARROW = "(max-width: 799.98px)";
var RETURN = "rst-shell-return", WENT_BACK = "rst-shell-back";
@@ -154,4 +159,26 @@
history.back();
}
});
+
+ // 4. Shown to be measured: cut, the name or the link in it is wider
+ // inside than out. Synchronous, so the shown state never paints.
+ // The console's is in the bar after the up link; the sidebar's is in
+ // the rail of a root holding one, as tokens.css matches it.
+ var T = ":is([rst-shell-title],[rst-shell-brand],.rst-shell__title,.rst-shell__brand)";
+ var NAME = ":is([rst-shell-up],.rst-shell__up)~" + T + ",:is([rst-shell-sidebar],.rst-shell-sidebar):has([rst-shell-up],.rst-shell__up)>:is([rst-shell-rail],.rst-shell__rail)>" + T;
+ function cut(n) {
+ var all = [n].concat([].slice.call(n.querySelectorAll("*"))), i;
+ for (i = 0; i < all.length; i++) if (all[i].scrollWidth > all[i].clientWidth) return true;
+ return false;
+ }
+ function fit() {
+ var names = document.querySelectorAll(NAME), i, n;
+ for (i = 0; i < names.length; i++) {
+ n = names[i];
+ n.hidden = false;
+ n.hidden = matchMedia(NARROW).matches && n.getClientRects().length > 0 && cut(n);
+ }
+ }
+ if (window.ResizeObserver) new ResizeObserver(fit).observe(document.documentElement);
+ window.addEventListener("load", fit);
})();
diff --git a/internal/fichas/static/theme.css b/internal/fichas/static/theme.css
index 91c65a9..154520b 100644
--- a/internal/fichas/static/theme.css
+++ b/internal/fichas/static/theme.css
@@ -84,6 +84,122 @@
--rst-shadow-knob: 0 1px 2px rgba(20, 24, 33, 0.3);
--rst-shadow-lift: 0 1px 1px rgba(20, 24, 33, 0.04), 0 14px 36px -14px light-dark(rgba(20, 24, 33, 0.22), rgba(0, 0, 0, 0.55));
--rst-overlay: light-dark(rgba(20, 24, 33, 0.45), rgba(0, 0, 0, 0.6));
+
+ /* ── Tokens rastrillo added after v0.23.0 ──────────────────────────
+ rastrillo v0.37.0 (its look from Fiesta 1.3.0) has day declare these
+ 69 tokens beyond the set Calma was built on; v0.38.0 (Fiesta 1.5.0)
+ declares the same 69. Each is set to the fallback rastrillo v0.38.0's
+ tokens.css uses where it reads it, so rastrillo's own stylesheet draws
+ exactly what it would with none declared, and the gate
+ (TestDeclaresRastrilloTokens) stays strict. Two moved at v0.38.0:
+ --rst-focus-edge (below) and --rst-ghost-face-hover (after this
+ block). An app's CSS that reads one of these with a different
+ fallback of its own does change (Fichas' rail; AGENTS.md, Theme).
+ Adopting Fiesta's depth, light and sheen, or any value here other
+ than its fallback, is a separate design decision for Paul (AGENTS.md,
+ Theme), not a pin bump. */
+
+ /* Filled buttons: the accent and danger fills, their edges and labels. */
+ --rst-accent-fill: var(--rst-accent);
+ --rst-accent-fill-hover: var(--rst-accent-strong);
+ --rst-accent-fill-edge: var(--rst-accent);
+ --rst-accent-fill-edge-hover: var(--rst-accent-strong);
+ --rst-on-accent-fill: var(--rst-on-accent);
+ --rst-danger-fill: var(--rst-tone-negative-fg);
+ --rst-danger-fill-hover: var(--rst-tone-negative-fg);
+ --rst-danger-fill-edge: var(--rst-tone-negative-fg);
+ --rst-danger-fill-edge-hover: var(--rst-tone-negative-fg);
+ --rst-on-danger-fill: var(--rst-on-accent);
+ --rst-on-danger-fill-hover: var(--rst-on-accent);
+ --rst-danger-hover-filter: brightness(0.9);
+
+ /* Controls, ghost buttons and disclosure summaries. */
+ --rst-control-face: var(--rst-surface);
+ --rst-control-face-hover: var(--rst-surface);
+ --rst-control-face-press: transparent;
+ --rst-control-border: var(--rst-line-strong);
+ --rst-control-border-hover: var(--rst-accent);
+ --rst-control-text-hover: var(--rst-accent);
+ --rst-ghost-edge: var(--rst-line-strong);
+ --rst-ghost-edge-hover: var(--rst-line-strong);
+ --rst-ghost-face-hover: transparent;
+ --rst-summary-face: transparent;
+ --rst-summary-face-hover: transparent;
+ --rst-summary-edge: transparent;
+ --rst-summary-edge-hover: transparent;
+ --rst-summary-radius: 0;
+
+ /* Focus, hover and press tints. */
+ /* The field's edge on focus. Fiesta 1.5.0 draws one focus ring: the
+ edge turns to this, and the 2px accent outline sits flush on it. Its
+ fallback moved from --rst-line-strong to the accent at v0.38.0, and
+ the one ring depends on it (a grey edge under an accent outline reads
+ as two). */
+ --rst-focus-edge: var(--rst-accent);
+ --rst-focus-halo: transparent;
+ --rst-tint-hover: var(--rst-accent-soft);
+ --rst-tint-press: var(--rst-accent-soft);
+ --rst-tint-tap: transparent;
+ --rst-tint-card-hover: transparent;
+ --rst-tint-group-hover: transparent;
+ --rst-tint-tile-hover: var(--rst-surface);
+ --rst-tint-tile-press: var(--rst-surface);
+ --rst-row-tint-hover: var(--rst-surface-2);
+ --rst-row-tint-press: var(--rst-surface-2);
+
+ /* Fiesta's depth, light and sheen: all off, as the fallbacks have them. */
+ --rst-depth-face: 0;
+ --rst-depth-hl: transparent;
+ --rst-depth-contact: transparent;
+ --rst-depth-ambient: transparent;
+ --rst-light-rim: var(--rst-line);
+ --rst-light-wash: transparent;
+ --rst-sheen-fill: transparent;
+ --rst-sheen-plain: transparent;
+ --rst-press-drop: 0px;
+ --rst-press-wash: 0;
+ --rst-press-spot: 0;
+ --rst-press-wash-plain: 0;
+ --rst-press-spot-plain: 0;
+
+ /* Switches. */
+ --rst-knob: var(--rst-surface);
+ --rst-knob-shade: var(--rst-surface);
+ --rst-shadow-knob-hover: var(--rst-shadow-knob);
+ --rst-track-off: var(--rst-line-strong);
+ --rst-switch-w: 34px;
+ --rst-switch-h: 19px;
+ --rst-switch-knob: 15px;
+ --rst-switch-touch-w: 34px;
+ --rst-switch-touch-h: 19px;
+ --rst-switch-touch-knob: 15px;
+
+ /* Type and navigation. */
+ --rst-title-size: 1.375rem;
+ --rst-title-weight: 600;
+ --rst-title-track: -0.015em;
+ --rst-heading-size: var(--rst-fs-base);
+ --rst-label-case: uppercase;
+ --rst-label-track: 0.06em;
+ --rst-rail-bg: var(--rst-surface);
+ --rst-nav-current-bg: var(--rst-accent-soft);
+ --rst-nav-current-fg: var(--rst-accent);
+}
+
+/* --rst-ghost-face-hover has two fallbacks in rastrillo v0.38.0's
+ tokens.css: a ghost button's hover reads it with `transparent`, and the
+ one-way sign-in door's quiet controls (Other ways to sign in, Back, Use
+ a different email) with --rst-surface-2, the soft pill under them on
+ hover and focus. One value at :root cannot be both, so the smart door
+ (chrome's estilo-signin-screen) gets its own. Every ghost button inside
+ that screen gets the pill, and the door drawn outside it gets none
+ (AGENTS.md, Theme). Keyed on estilo's hook, not the partial's rst-
+ names, which are rastrillo's (AGENTS.md, Vocabulary). Not in print,
+ where Fiesta clears hover faces. */
+@media not print {
+ [estilo-signin-screen] {
+ --rst-ghost-face-hover: var(--rst-surface-2);
+ }
}
/* The whole toggle. Setting color-scheme re-resolves every light-dark()
diff --git a/internal/fichas/static/tokens.css b/internal/fichas/static/tokens.css
index 6abd02f..3ae9664 100644
--- a/internal/fichas/static/tokens.css
+++ b/internal/fichas/static/tokens.css
@@ -235,7 +235,7 @@ body {
component that sizes its icon (the 12px caret, .rst-caret) still
wins. Not the list grid's title: it is the row's name, text that an
icon should follow, and the row is its target. */
-:where(.rst-btn, .rst-search, .rst-search__clear, .rst-ftok a, .rst-help, .rst-dropdown > summary, .rst-dropdown__menu a, .rst-dropdown__menu button, .rst-dropdown__menu .rst-menu-group > summary, .rst-row-menu__panel a, .rst-row-menu__panel button, .rst-locale button, .rst-scheme button, .rst-combo__option, .rst-dtp__row, .rst-dtp__pick, .rst-cal__nav, .rst-row__action, .rst-row-menu > summary, .rst-pagination > a, .rst-seg-tabs a, .rst-seg-tabs > button, .rst-side__nav a, .rst-switch, .rst-choice__cards label, .rst-tblock__head, .rst-bulkbar__close, .rst-bulkbar__escalate, .rst-modal-close, .rst-modal-panel > nav a, .rst-back-nav a, .rst-signin__providers > a, .rst-shell__brand, .rst-shell__nav a, .rst-shell__menu > summary, .rst-shell__chrome > summary, .rst-shell__account > summary, .rst-shell__back > a) .icon, :where([rst-btn], [rst-search], [rst-search-clear], [rst-ftok] a, [rst-help], [rst-dropdown] > summary, [rst-dropdown-menu] a, [rst-dropdown-menu] button, [rst-dropdown-menu] [rst-menu-group] > summary, [rst-row-menu-panel] a, [rst-row-menu-panel] button, [rst-locale] button, [rst-scheme] button, [rst-combo-option], [rst-dtp-row], [rst-dtp-pick], [rst-cal-nav], [rst-row-action], [rst-row-menu] > summary, [rst-pagination] > a, [rst-seg-tabs] a, [rst-seg-tabs] > button, [rst-side-nav] a, [rst-switch], [rst-choice-cards] label, [rst-tblock-head], [rst-bulkbar-close], [rst-bulkbar-escalate], [rst-modal-close], [rst-modal-panel] > nav a, [rst-back-nav] a, [rst-signin-providers] > a, [rst-shell-brand], [rst-shell-nav] a, [rst-shell-menu] > summary, [rst-shell-chrome] > summary, [rst-shell-account] > summary, [rst-shell-back] > a) .icon {
+:where(.rst-btn, .rst-search, .rst-search__clear, .rst-ftok a, .rst-help, .rst-dropdown > summary, .rst-dropdown__menu a, .rst-dropdown__menu button, .rst-dropdown__menu .rst-menu-group > summary, .rst-row-menu__panel a, .rst-row-menu__panel button, .rst-locale button, .rst-scheme button, .rst-combo__option, .rst-dtp__row, .rst-dtp__pick, .rst-cal__nav, .rst-row__action, .rst-row-menu > summary, .rst-pagination > a, .rst-seg-tabs a, .rst-seg-tabs > button, .rst-side__nav a, .rst-switch, .rst-choice__cards label, .rst-tblock__head, .rst-bulkbar__close, .rst-bulkbar__escalate, .rst-modal-close, .rst-modal-panel > nav a, .rst-back-nav a, .rst-signin__providers > a, .rst-shell__brand, .rst-shell__nav a, .rst-shell__menu > summary, .rst-shell__chrome > summary, .rst-shell__account > summary, .rst-shell__back > a, .rst-shell__up) .icon, :where([rst-btn], [rst-search], [rst-search-clear], [rst-ftok] a, [rst-help], [rst-dropdown] > summary, [rst-dropdown-menu] a, [rst-dropdown-menu] button, [rst-dropdown-menu] [rst-menu-group] > summary, [rst-row-menu-panel] a, [rst-row-menu-panel] button, [rst-locale] button, [rst-scheme] button, [rst-combo-option], [rst-dtp-row], [rst-dtp-pick], [rst-cal-nav], [rst-row-action], [rst-row-menu] > summary, [rst-pagination] > a, [rst-seg-tabs] a, [rst-seg-tabs] > button, [rst-side-nav] a, [rst-switch], [rst-choice-cards] label, [rst-tblock-head], [rst-bulkbar-close], [rst-bulkbar-escalate], [rst-modal-close], [rst-modal-panel] > nav a, [rst-back-nav] a, [rst-signin-providers] > a, [rst-shell-brand], [rst-shell-nav] a, [rst-shell-menu] > summary, [rst-shell-chrome] > summary, [rst-shell-account] > summary, [rst-shell-back] > a, [rst-shell-up]) .icon {
block-size: 1rem;
inline-size: 1rem;
}
@@ -1792,6 +1792,76 @@ a.rst-nm:hover { color: var(--rst-accent); }
.rst-locale button:hover:active, .rst-scheme button:hover:active, [rst-locale] button:hover:active, [rst-scheme] button:hover:active { background: var(--rst-tint-press, var(--rst-accent-soft)); }
}
.rst-locale button[aria-current], .rst-scheme button[aria-current], [rst-locale] button[aria-current], [rst-scheme] button[aria-current] { color: var(--rst-accent); font-weight: 600; }
+/* A row in an account card: a muted label at the start, a control at
+ the end, or under the label where the card is too narrow for both
+ (the sidebar's rail-wide card where anchors are missing). */
+.rst-menu-row, [rst-menu-row] { align-items: center; display: flex; flex-wrap: wrap; gap: var(--rst-sp-3); justify-content: space-between; min-block-size: var(--rst-target); padding-block: 0.25rem; padding-inline: 0.65rem; }
+.rst-menu-row__label, [rst-menu-row-label] { color: var(--rst-text-muted); font-size: 12.5px; }
+/* A menu in a row (the Language menu) opens IN PLACE, as the 1.3
+ card's and the sidebar profile's do: as a popover over the card it
+ covered the account's links under it. Open, the row lines up on the
+ label's and the summary's text, since the summary now has the list
+ under it. */
+.rst-menu-row:has(> .rst-dropdown[open]), [rst-menu-row]:has(> [rst-dropdown][open]) { align-items: baseline; }
+.rst-menu-row .rst-dropdown__menu, [rst-menu-row] [rst-dropdown-menu] { border: 0; box-shadow: none; inset: auto; margin: 0; max-block-size: none; min-width: 0; padding-block: 0; padding-inline: 0; position: static; }
+/* The Language row's list is a popover: a button with popovertarget
+ opens it and the browser closes it (a tap outside, Escape, or the
+ sheet's own Close), with no script. It never opens inside the card,
+ which keeps its height. The button wears the summary's face.
+
+ Below 800px the list is a sheet over the page: the fixed viewport's
+ width (a scrollbar gutter the root reserves is outside it, and would
+ clip a wider sheet), on the bottom edge, under a heading row (the
+ row's own shape: the heading at the start, Close at the end) and
+ over the overlay. No rule under the heading: a step of space, so the
+ current language's tint never touches it. From 800px it is a menu beside the card, anchored
+ to the card's box (--rst-card): at its inline start, top to top, or
+ flipped to its other side or upward where there is no room. The
+ heading row is a phone's only. Without anchor positioning the menu
+ is where the browser puts a popover, centred in the window.
+
+ An engine with no popover (Firefox 121-124) has a <details> in the
+ row too, after the button, whose summary is the same face: the
+ @supports pair shows the one mechanism the engine has, its open
+ <details> shows the list, the next sibling, in the row as the 1.3
+ card did, and every rule naming :popover-open is a rule that engine
+ drops whole. */
+.rst-menu-row > [popovertarget], [rst-menu-row] > [popovertarget] { color: var(--rst-text-muted); display: flex; font-size: 12.5px; gap: 0.3rem; inline-size: auto; padding: 0.4rem 0.6rem; white-space: nowrap; }
+.rst-dropdown__menu:has(> .rst-menu-row), [rst-dropdown-menu]:has(> [rst-menu-row]) { anchor-name: --rst-card; }
+.rst-menu-row > :popover-open, [rst-menu-row] > :popover-open { background: var(--rst-surface); border: 1px solid var(--rst-line); border-radius: 9px; box-shadow: var(--rst-shadow-pop); color: var(--rst-text); min-inline-size: 176px; padding: 0.25rem; }
+.rst-menu-row > [popover] > .rst-menu-row, [rst-menu-row] > [popover] > [rst-menu-row] { margin-block-end: var(--rst-sp-2); }
+.rst-menu-row > [popover] h2, [rst-menu-row] > [popover] h2 { font-size: var(--rst-fs-base); margin: 0; }
+.rst-menu-row [popovertargetaction=hide], [rst-menu-row] [popovertargetaction=hide] { color: var(--rst-accent); font-size: var(--rst-fs-sm); }
+@supports selector(:popover-open) {
+ .rst-menu-row > [popovertarget] + .rst-dropdown, [rst-menu-row] > [popovertarget] + [rst-dropdown] { display: none; }
+}
+@supports not selector(:popover-open) {
+ .rst-menu-row > [popovertarget], [rst-menu-row] > [popovertarget], .rst-menu-row > [popover] > .rst-menu-row, [rst-menu-row] > [popover] > [rst-menu-row], .rst-menu-row > .rst-dropdown:not([open]) + [popover], [rst-menu-row] > [rst-dropdown]:not([open]) + [popover] { display: none; }
+ .rst-menu-row > [popover], [rst-menu-row] > [popover] { flex-basis: 100%; }
+}
+@media (max-width: 799.98px) {
+ .rst-menu-row > :popover-open, [rst-menu-row] > :popover-open { border-radius: 14px 14px 0 0; border-width: 1px 0 0; inline-size: auto; inset: auto 0 0; margin: 0; max-block-size: calc(100dvh - 3rem); }
+ .rst-menu-row > :popover-open::backdrop, [rst-menu-row] > :popover-open::backdrop { background: var(--rst-overlay); }
+}
+@media (min-width: 800px) {
+ .rst-menu-row > [popover] > .rst-menu-row, [rst-menu-row] > [popover] > [rst-menu-row] { display: none; }
+ @supports (position-area: block-end) and (position-try-fallbacks: flip-block) {
+ .rst-menu-row > :popover-open, [rst-menu-row] > :popover-open { inset: auto; margin: 0 4px; position-anchor: --rst-card; position-area: inline-start span-block-end; position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline; }
+ }
+}
+/* The account summary carries two faces, as the console's Menu did: the
+ avatar, and the word Account with its caret. Below 800px it is the
+ avatar alone, the end of the phone's one header row; from 800px it
+ is "Account" and the caret, the desktop bar's account menu as it
+ was. Keyed on the label, so an account menu written before it, a
+ plain "Account" summary, keeps its caret everywhere. */
+.rst-shell__account > summary .rst-shell__account-label, [rst-shell-account] > summary [rst-shell-account-label] { display: inline; }
+@media (max-width: 799.98px) {
+ .rst-shell__account > summary .rst-shell__account-label, [rst-shell-account] > summary [rst-shell-account-label], .rst-shell__account > summary:has(.rst-shell__account-label) > .rst-caret, [rst-shell-account] > summary:has([rst-shell-account-label]) > [rst-caret] { display: none; }
+}
+@media (min-width: 800px) {
+ .rst-shell__account > summary:has(.rst-shell__account-label) > .rst-shell__avatar, [rst-shell-account] > summary:has([rst-shell-account-label]) > [rst-shell-avatar] { display: none; }
+}
/* Task 2's menu only ever held links; bulk-bar's actions menu (Task 4)
is real submit buttons on the surrounding form, so the same panel
needs button styling too — mirrors .rst-row-menu__panel's combined
@@ -1802,6 +1872,25 @@ a.rst-nm:hover { color: var(--rst-accent); }
.rst-dropdown__menu button:not(.rst-danger):hover, [rst-dropdown-menu] button:not(.rst-danger):hover { background: var(--rst-tint-hover, var(--rst-accent-soft)); box-shadow: inset 0 1px 0 var(--rst-depth-hl, transparent); }
.rst-dropdown__menu button:not(.rst-danger):hover:active, [rst-dropdown-menu] button:not(.rst-danger):hover:active { background: var(--rst-tint-press, var(--rst-accent-soft)); }
}
+/* The icon scheme control: Light, Dark and System as three icon
+ buttons in one row, joined in a soft track with a shared edge. The
+ current one is raised the way a seg-tabs current item is. The
+ buttons are a menu row's own, not a dropdown's items, so they drop
+ the full-width block face of the scheme and menu buttons above and
+ take the icon's size. Each is drawn small, 32 by 24px, a menu row's
+ control rather than a row of buttons, and its tap is its ::after, the
+ target floor each way around its centre: the track's gap and inline
+ padding make room for those hit cells, 2px apart, so a finger's
+ 44px cells never overlap and a mouse's 32px ones sit as close as the
+ segments do. The buttons name their attribute twice to outweigh the
+ floor's menu-button minimums, and the current button to outweigh the
+ card's hover and press, (0,3,1). Each selector ends in what the rules
+ above end in, so the control still answers to [rst-scheme] and to
+ the script. */
+.rst-scheme--icons, [rst-scheme~="icons"] { align-items: center; background: var(--rst-bg); border: 1px solid var(--rst-line); border-radius: 8px; display: inline-flex; flex: none; gap: calc(var(--rst-target) - 2rem + 2px); padding: 2px max(2px, (var(--rst-target) - 2rem) / 2); }
+.rst-scheme--icons.rst-scheme--icons button, [rst-scheme~="icons"][rst-scheme~="icons"] button { align-items: center; block-size: 1.5rem; color: var(--rst-text-muted); display: flex; inline-size: 2rem; justify-content: center; min-block-size: 0; min-inline-size: 0; padding: 0; position: relative; }
+.rst-scheme--icons button::after, [rst-scheme~="icons"] button::after { content: ""; inset: calc((100% - var(--rst-target)) / 2); position: absolute; }
+.rst-scheme--icons.rst-scheme--icons button[aria-current], [rst-scheme~="icons"][rst-scheme~="icons"] button[aria-current] { background: var(--rst-surface); box-shadow: inset var(--rst-hl-x) 1px 0 var(--rst-depth-hl, transparent), var(--rst-shadow-lift); color: var(--rst-text); font-weight: inherit; }
/* The same content-box bug the inputs had, in the three menu panels:
a full-width button inside a 0.25rem-padded panel measured 100% of
the content box and then added its own 0.65rem of side padding, so
@@ -2015,11 +2104,39 @@ details[open] > summary > .rst-caret, details[open] > summary > [rst-caret] { tr
@media (pointer: coarse), (max-width: 40rem) {
.rst-input, [rst-input] { font-size: max(1rem, 1em); }
}
+/* iOS Safari draws a date, time or datetime-local input as its own
+ native control, and while it does the control keeps a minimum width
+ of its own that width: 100% does not shrink: on a phone the field ran
+ past its column and the page scrolled sideways (discussion #46).
+ Taking the field off the native appearance gives it the width its
+ column gives every other field; a tap still opens the native picker.
+ Only the appearance: a display here would outrank the UA's [hidden]
+ and .rst-m-hide, and desktop Safari pads a block date field's inside.
+ Neither min-width: 0 nor max-width: 100% is needed: the floor block
+ below already replaces the automatic minimum, and a minimum wins over
+ a maximum anyway. Nor a height: an empty field, with no text to hold
+ it open, is held at --rst-target by the same floor.
+ check/datefield_phone_browser_test.go stands in the native minimum,
+ since no browser off an iPhone draws it. */
+input.rst-input[type="date"], input.rst-input[type="time"], input.rst-input[type="datetime-local"], input[rst-input][type="date"], input[rst-input][type="time"], input[rst-input][type="datetime-local"] { -webkit-appearance: none; appearance: none; }
+/* Off the native appearance, iOS centres the value; a field's text
+ starts at its start edge, as a text field's does. A rule of its own:
+ a browser that does not know the pseudo-element drops the rule. */
+input.rst-input::-webkit-date-and-time-value, input[rst-input]::-webkit-date-and-time-value { text-align: start; }
/* A field sits slightly into the page: a 1px inset ambient shadow, and
- the control border, which stays --rst-line-strong at 3:1. Focus adds
- the focus edge and a 3px halo; the solid 2px outline stays, because
- the halo is extra and never the indicator. */
-.rst-input:focus-visible, [rst-input]:focus-visible { border-color: var(--rst-focus-edge, var(--rst-line-strong)); box-shadow: inset 0 1px 1px var(--rst-depth-ambient, transparent), 0 0 0 3px var(--rst-focus-halo, transparent); outline: 2px solid var(--rst-accent); outline-offset: 2px; }
+ the control border, which stays --rst-line-strong at 3:1. Focus is one
+ ring, not two: the field's own edge turns to the focus edge, the 2px
+ accent outline sits flush against it, and the 3px halo flush against
+ that. The outline used to stand 2px off a grey edge, and the edge, the
+ gap and the outline read as a double border. The outline is still the
+ indicator, never the halo: the edge changes from --rst-line-strong to
+ the accent at under 3:1 in every theme (1.7:1 in Day), and the halo
+ from the surface at 1.4:1, so neither counts toward WCAG 2.4.13; the
+ outline's 2px, drawn from the surface, are 5.5:1 to 18.9:1. A halo of
+ 5px is 3px past the outline. Forced colours drop the edge colour and
+ the halo and keep the outline, in the reader's own colour.
+ check/focus_ring_browser_test.go measures it. */
+.rst-input:focus-visible, [rst-input]:focus-visible { border-color: var(--rst-focus-edge, var(--rst-accent)); box-shadow: inset 0 1px 1px var(--rst-depth-ambient, transparent), 0 0 0 5px var(--rst-focus-halo, transparent); outline: 2px solid var(--rst-accent); outline-offset: 0; }
/* short is compact, not tiny: 8rem is a border-box width, so it renders
within a pixel or two of the old 6.5rem content box plus its padding,
and it is wide enough for the postcodes and codes it is for. The
@@ -2049,7 +2166,7 @@ textarea.rst-input, textarea[rst-input] { min-height: 5rem; resize: vertical; }
.rst-textarea, [rst-textarea] { font-size: max(1rem, 1em); }
}
/* Sunk and focused as .rst-input is, for the reason given there. */
-.rst-textarea:focus-visible, [rst-textarea]:focus-visible { border-color: var(--rst-focus-edge, var(--rst-line-strong)); box-shadow: inset 0 1px 1px var(--rst-depth-ambient, transparent), 0 0 0 3px var(--rst-focus-halo, transparent); outline: 2px solid var(--rst-accent); outline-offset: 2px; }
+.rst-textarea:focus-visible, [rst-textarea]:focus-visible { border-color: var(--rst-focus-edge, var(--rst-accent)); box-shadow: inset 0 1px 1px var(--rst-depth-ambient, transparent), 0 0 0 5px var(--rst-focus-halo, transparent); outline: 2px solid var(--rst-accent); outline-offset: 0; }
/* The textarea grows with its text: field-sizing: content, from the
5rem minimum above (which the touch query leaves alone, so a phone
keeps it too) to half the viewport, past which it scrolls. Half,
@@ -2929,6 +3046,9 @@ dialog.rst-modal-panel, dialog[rst-modal-panel] { block-size: auto; color: inher
.rst-shell__profile .rst-dropdown__menu .rst-dropdown__menu, [rst-shell-profile] [rst-dropdown-menu] [rst-dropdown-menu] { border: 0; box-shadow: none; inset: auto; margin: 0; max-block-size: none; min-width: 0; padding-block: 0; padding-inline: 0.5rem 0; position: static; }
.rst-shell__profile .rst-dropdown__menu .rst-dropdown > summary, [rst-shell-profile] [rst-dropdown-menu] [rst-dropdown] > summary { border-radius: var(--rst-radius-sm); color: var(--rst-text); font-size: var(--rst-fs-sm); justify-content: space-between; padding: 0.4rem 0.65rem; }
.rst-shell__profile .rst-dropdown__menu .rst-dropdown > summary:hover, [rst-shell-profile] [rst-dropdown-menu] [rst-dropdown] > summary:hover { background: var(--rst-accent-soft); }
+/* In an account card's row the value (the current language) is set
+ as the row's label is; its caret is what marks it a menu. */
+.rst-dropdown__menu .rst-menu-row > .rst-dropdown > summary, [rst-dropdown-menu] [rst-menu-row] > [rst-dropdown] > summary { font-size: 12.5px; font-weight: inherit; }
@media (min-width: 800px) {
.rst-shell-sidebar, [rst-shell-sidebar] { display: grid; grid-template-columns: 15rem 1fr; }
/* LEGACY: the old drawer, see above. */
@@ -3199,6 +3319,10 @@ dialog.rst-modal-panel, dialog[rst-modal-panel] { block-size: auto; color: inher
back strip and the title are hidden by the rule just below, and
nothing here needs undoing. ─────────────────────────────────────── */
.rst-shell__back, [rst-shell-back], .rst-shell__title, [rst-shell-title] { display: none; }
+/* The up link, the one-row shells' way back: only a content page on a
+ phone shows it (each shell's own block). Hidden everywhere else,
+ the index included, which writes it all the same. */
+.rst-shell__up, [rst-shell-up] { display: none; }
/* The heading's two spans: the brand, then the page's title, which
shows only when the brand's span rendered nothing, so an app that
blanks its brand still has a heading. Each elides on its one line.
@@ -3345,6 +3469,206 @@ dialog.rst-modal-panel, dialog[rst-modal-panel] { block-size: auto; color: inher
.rst-shell-console--index .rst-shell__tail > .rst-shell__account > .rst-dropdown__menu, [rst-shell-console~="index"] [rst-shell-tail] > [rst-shell-account] > [rst-dropdown-menu] { padding-inline: 0; }
}
}
+/* ── The console on one row ─────────────────────────────────────────
+ A console whose root holds [rst-shell-up] is the one-row console.
+ Below 800px its bar is the phone's one header row: the up link at
+ the inline start, the app's name at the centre, the account's avatar
+ at the inline end, and nothing else above the page. The back strip,
+ the Menu and its tail are gone: the up link is in the bar, and the
+ account card holds the person, the scheme, the language and the
+ account's links. From 800px it is the 1.3 bar less the language
+ menu, which moved into the card: the brand at the start, "Account"
+ at the end. Every rule names [rst-shell-up], in the root's :has()
+ or as the element itself, so a 1.3 console (Menu, tail, back strip)
+ matches none of them and draws as it did. The card is as tall as
+ the window less the row, as the 1.3 card was: it holds four kinds
+ of thing now, and the Language menu opens inside it.
+
+ The row is a grid of three columns, the two sides equal shares of
+ what the name leaves, each at least its own content, so the name is
+ on the row's true centre whenever it can be and moves toward the
+ shorter side only as far as it must. The name's column shrinks when
+ the three do not fit, and the name keeps to one line, cut with an
+ ellipsis, so the up link and the avatar never give up any of their
+ width to it. The up link's own label is cut with an ellipsis too,
+ at the screen's width less the avatar's column, so a long parent
+ title never pushes the avatar off the row; its aria-label keeps the
+ whole title. A name is shown whole or not at all, never cut: shell.js
+ measures it and, where it is cut, marks it hidden, which the [hidden]
+ rule takes out of the row, out of reach of a tap and of Tab. Only a
+ script can tell that a name is cut, so with scripts off the cut name
+ stays, the one place the ellipsis shows: a tap or Tab there lands on
+ a name the reader can see, never on an invisible link. */
+.rst-shell-console:has(.rst-shell__up) .rst-shell__account > .rst-dropdown__menu, [rst-shell-console]:has([rst-shell-up]) [rst-shell-account] > [rst-dropdown-menu], .rst-shell-topbar:has(.rst-shell__up) .rst-shell__account > .rst-dropdown__menu, [rst-shell-topbar]:has([rst-shell-up]) [rst-shell-account] > [rst-dropdown-menu] { box-sizing: border-box; inline-size: min(17rem, calc(100vw - 1.5rem)); max-block-size: calc(100dvh - 5rem); }
+@media (max-width: 799.98px) {
+ /* The sidebar's card only on a phone: from 800px it is the rail
+ foot's drop-up, as wide as the rail where it cannot escape it. */
+ .rst-shell-sidebar:has(.rst-shell__up) .rst-shell__profile > .rst-dropdown__menu, [rst-shell-sidebar]:has([rst-shell-up]) [rst-shell-profile] > [rst-dropdown-menu] { box-sizing: border-box; inline-size: min(17rem, calc(100vw - 1.5rem)); max-block-size: calc(100dvh - 5rem); }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar], .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] { align-items: center; block-size: var(--rst-shell-strip); display: grid; gap: 0 var(--rst-sp-1); grid-template-columns: minmax(max-content, 1fr) minmax(0, max-content) minmax(max-content, 1fr); padding-inline: var(--rst-sp-1); }
+ /* A content page's row stays at the top as the back strip did,
+ above the sticky form bar (5) and below a modal's scrim (10). */
+ .rst-shell-console--page:has(.rst-shell__up) > .rst-shell__bar, [rst-shell-console~="page"]:has([rst-shell-up]) > [rst-shell-bar], .rst-shell-topbar--page:has(.rst-shell__up) > .rst-shell__bar, [rst-shell-topbar~="page"]:has([rst-shell-up]) > [rst-shell-bar] { inset-block-start: 0; position: sticky; z-index: 9; }
+ .rst-shell-console--page > .rst-shell__bar > .rst-shell__up, [rst-shell-console~="page"] > [rst-shell-bar] > [rst-shell-up], .rst-shell-sidebar--page > .rst-shell__bar > .rst-shell__up, [rst-shell-sidebar~="page"] > [rst-shell-bar] > [rst-shell-up], .rst-shell-topbar--page > .rst-shell__bar > .rst-shell__up, [rst-shell-topbar~="page"] > [rst-shell-bar] > [rst-shell-up] { border-radius: var(--rst-radius-sm); box-sizing: border-box; color: var(--rst-accent); display: block; font-size: 1rem; font-weight: 500; grid-column: 1; grid-row: 1; justify-self: start; line-height: 2.75rem; max-inline-size: calc(100vw - 5rem); min-block-size: 2.75rem; min-inline-size: var(--rst-target); overflow: hidden; padding-inline: 0.25rem 0.5rem; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
+ .rst-shell__up > .icon, [rst-shell-up] > .icon { margin-inline-end: 0.25rem; vertical-align: middle; }
+ [dir="rtl"] .rst-shell-console--page > .rst-shell__bar > .rst-shell__up .icon, [dir="rtl"] [rst-shell-console~="page"] > [rst-shell-bar] > [rst-shell-up] .icon, [dir="rtl"] .rst-shell-sidebar--page > .rst-shell__bar > .rst-shell__up .icon, [dir="rtl"] [rst-shell-sidebar~="page"] > [rst-shell-bar] > [rst-shell-up] .icon, [dir="rtl"] .rst-shell-topbar--page > .rst-shell__bar > .rst-shell__up .icon, [dir="rtl"] [rst-shell-topbar~="page"] > [rst-shell-bar] > [rst-shell-up] .icon { transform: scaleX(-1); }
+ .rst-shell-console--page > .rst-shell__bar > .rst-shell__up:focus-visible, [rst-shell-console~="page"] > [rst-shell-bar] > [rst-shell-up]:focus-visible, .rst-shell-sidebar--page > .rst-shell__bar > .rst-shell__up:focus-visible, [rst-shell-sidebar~="page"] > [rst-shell-bar] > [rst-shell-up]:focus-visible, .rst-shell-topbar--page > .rst-shell__bar > .rst-shell__up:focus-visible, [rst-shell-topbar~="page"] > [rst-shell-bar] > [rst-shell-up]:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: -2px; }
+ /* The name: the brand on a page, the title (which holds the brand)
+ on the index. One face for both, so the row does not change as the
+ slide goes between them. */
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand],
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__title, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-title],
+ .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand],
+ .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__title, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-title],
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__brand, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-brand],
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__title, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-title] { block-size: 2.75rem; color: var(--rst-text); font-size: var(--rst-fs-lg); font-weight: 650; grid-column: 2; grid-row: 1; justify-content: center; letter-spacing: normal; line-height: 2.75rem; margin: 0; min-block-size: 0; min-inline-size: 0; overflow: hidden; padding: 0; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
+ .rst-shell-console--page:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand, [rst-shell-console~="page"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand], .rst-shell-topbar--page:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand, [rst-shell-topbar~="page"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand] { display: block; }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand[hidden], [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand][hidden],
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__title[hidden], [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-title][hidden],
+ .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand[hidden], [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand][hidden],
+ .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__title[hidden], [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-title][hidden],
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__brand[hidden], [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-brand][hidden],
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__title[hidden], [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-title][hidden] { display: none; }
+ /* The avatar: a round 44px button, as the sidebar's profile is. */
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account], .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] { grid-column: 3; grid-row: 1; justify-self: end; margin-inline-start: 0; }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary, .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary { border-radius: 50%; box-sizing: border-box; color: var(--rst-text); display: inline-flex; justify-content: center; min-block-size: var(--rst-target); min-inline-size: var(--rst-target); padding: 4px; }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]) > .rst-shell__account > summary, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]) > [rst-shell-account] > summary, .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]) > .rst-shell__account > summary, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]) > [rst-shell-account] > summary { background: var(--rst-accent-soft); }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary:focus-visible, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary:focus-visible, .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary:focus-visible, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: 2px; }
+ /* CLOSING ON AN OUTSIDE TAP with scripts off, the 1.3 card's way:
+ while open the summary grows an invisible layer over the viewport,
+ under the card, and the bar is lifted above the page (45, as the
+ 1.3 bar was) only while it is. The open state is read off the bar,
+ so these stay rules of the account summary the tap inventory
+ names. */
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]) > .rst-shell__account > summary::before, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]) > [rst-shell-account] > summary::before, .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]) > .rst-shell__account > summary::before, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]) > [rst-shell-account] > summary::before { content: ""; cursor: default; inset: 0; position: fixed; z-index: 1; }
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]), [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]), .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar:has(> .rst-shell__account[open]), [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar]:has(> [rst-shell-account][open]) { z-index: 45; }
+}
+@media (max-width: 799.98px) and (hover: hover) {
+ .rst-shell-console:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary:hover, [rst-shell-console]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary:hover, .rst-shell-topbar:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__account > summary:hover, [rst-shell-topbar]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-account] > summary:hover { background: var(--rst-accent-soft); }
+}
+/* ── The sidebar on one row ─────────────────────────────────────────
+ A sidebar whose root holds [rst-shell-up] is the one-row sidebar.
+ Below 800px it draws the console's row (above) without a bar of its
+ own to hold it: its <header rst-shell-bar> holds only the up link,
+ and the brand (the title on the index) and the rail foot's profile
+ menu are placed into the row by layout. The root is a grid of the
+ row's three columns over the page; the rail is display: contents, so
+ its children are the root's grid items; the bar spans the row as a
+ subgrid, so the up link sizes the first column as if it were one of
+ them. Nothing is copied: app blocks can carry ids.
+
+ On a content page the nav is hidden and the page is the grid's
+ second row; on the index the nav rows are, and the avatar is read
+ after them, the one recorded exception to "focus order is visual
+ order" (the rail foot is last in the rail, and moving it in the DOM
+ would change the desktop's order too). main and the index's nav span
+ all three columns, and the sides' max-content minimum would take
+ their content's least width too, so a wide table in the page would
+ widen the row past the screen: contain: inline-size leaves them no
+ width of their own to lend, and they take the row's. The up link,
+ the name's face and the hidden-name rule are the console's, above,
+ which name the sidebar too.
+
+ A content page's row stays at the top as the back strip did, and
+ since a grid item sticks only inside its grid area, each of the
+ row's three items spans every row of the grid, starts at the top
+ and is sticky there, at the strip's z-index. From 800px the bar is
+ hidden and the rail and its drop-up are 1.3's. Every rule names
+ [rst-shell-up], so a 1.3 sidebar (back strip, lifted profile) or a
+ pre-index one (drawer) matches none of them. */
+.rst-shell-sidebar > .rst-shell__bar:has(> .rst-shell__up), [rst-shell-sidebar] > [rst-shell-bar]:has(> [rst-shell-up]) { display: none; }
+@media (max-width: 799.98px) {
+ .rst-shell-sidebar:has(.rst-shell__up), [rst-shell-sidebar]:has([rst-shell-up]) { column-gap: var(--rst-sp-1); display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, max-content) minmax(max-content, 1fr); grid-template-rows: var(--rst-shell-strip) auto; }
+ .rst-shell-sidebar > .rst-shell__bar:has(> .rst-shell__up), [rst-shell-sidebar] > [rst-shell-bar]:has(> [rst-shell-up]) { align-items: center; background: var(--rst-surface); block-size: var(--rst-shell-strip); border-block-end: 1px solid var(--rst-line); box-sizing: border-box; column-gap: var(--rst-sp-1); display: grid; grid-column: 1 / -1; grid-row: 1; grid-template-columns: subgrid; padding-inline: var(--rst-sp-1); }
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] { display: contents; }
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__brand, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-brand],
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__title, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-title] { align-self: center; grid-column: 2; grid-row: 1; }
+ .rst-shell-sidebar--page:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__brand, [rst-shell-sidebar~="page"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-brand] { display: block; }
+ /* The avatar at the inline end, as far in as the up link is. */
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__rail-foot, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-rail-foot] { align-items: center; align-self: center; block-size: auto; flex-direction: row; grid-column: 3; grid-row: 1; justify-self: end; margin: 0; margin-inline-end: var(--rst-sp-1); position: static; }
+ .rst-shell-sidebar:has(.rst-shell__up) > .rst-shell__main, [rst-shell-sidebar]:has([rst-shell-up]) > [rst-shell-main],
+ .rst-shell-sidebar--index:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__nav, [rst-shell-sidebar~="index"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-nav] { contain: inline-size; grid-column: 1 / -1; grid-row: 2; min-inline-size: 0; }
+ /* The index's rows, where 1.3's rail padding and heading gap put
+ them. */
+ .rst-shell-sidebar--index:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__nav, [rst-shell-sidebar~="index"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-nav] { margin: var(--rst-sp-2) var(--rst-sp-4) var(--rst-sp-5); }
+ .rst-shell-sidebar--page:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__nav, [rst-shell-sidebar~="page"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-nav] { display: none; }
+ /* Sticky on a content page, above the sticky form bar (5) and below
+ a modal's scrim (10). The name and the avatar sit 6px down the
+ strip, centred in it, and stick there. */
+ .rst-shell-sidebar--page > .rst-shell__bar:has(> .rst-shell__up), [rst-shell-sidebar~="page"] > [rst-shell-bar]:has(> [rst-shell-up]) { align-self: start; grid-row: 1 / -1; inset-block-start: 0; position: sticky; z-index: 9; }
+ .rst-shell-sidebar--page:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__brand, [rst-shell-sidebar~="page"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-brand],
+ .rst-shell-sidebar--page:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__rail-foot, [rst-shell-sidebar~="page"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-rail-foot] { align-self: start; grid-row: 1 / -1; inset-block-start: calc((var(--rst-shell-strip) - 2.75rem) / 2); margin-block-start: calc((var(--rst-shell-strip) - 2.75rem) / 2); position: sticky; z-index: 9; }
+ /* Lifted while the card is open, as the console's bar is. */
+ .rst-shell-sidebar--page:has(.rst-shell__up) > .rst-shell__rail > .rst-shell__rail-foot:has(.rst-shell__profile[open]), [rst-shell-sidebar~="page"]:has([rst-shell-up]) > [rst-shell-rail] > [rst-shell-rail-foot]:has([rst-shell-profile][open]) { z-index: 45; }
+}
+/* ── The topbar on one row ──────────────────────────────────────────
+ A topbar whose root holds [rst-shell-up] is the one-row topbar, and
+ below 800px a topbar app is a tree: /menu, the index, is the nav as
+ rows; every other page is a content page one level down from its
+ row there. The row is the console's (above): its grid, its up link
+ (labelled Menu, or the page's parent), its name and its avatar are
+ the console's rules, which name the topbar too. The index rows look
+ like the sidebar's and the console's, restated below in rules of
+ their own. The nav is in the bar, between the brand and the
+ account card: on a content page it is hidden, and on the index it
+ hangs from the bar's foot, out of the row's grid, so the row stays
+ the strip's height while its nav is the page, and the shell's foot
+ is anchored under it. main and its skip link go: the page is
+ navigation. The avatar is read after the rows, the order the bar
+ writes them in, the second recorded exception to "focus order is
+ visual order". Every rule here names [rst-shell-up].
+
+ From 800px the bar is 1.3's: the brand at the start, the nav inline,
+ Account at the end. The language menu has moved into the card, and
+ the up link and the title are hidden there as everywhere else. A
+ 1.3 topbar (a bare root, the Menu and its tail) has no
+ [rst-shell-up] and no view, so it matches none of these rules nor
+ the shared ones, and keeps its Menu card on a phone. */
+@media (max-width: 799.98px) {
+ .rst-shell-topbar--page:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav, [rst-shell-topbar~="page"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav],
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__brand, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-brand],
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-skip, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-skip],
+ .rst-shell-topbar--index:has(.rst-shell__up) > main, [rst-shell-topbar~="index"]:has([rst-shell-up]) > main { display: none; }
+ /* A content page's row is sticky, so a #fragment lands below it, as
+ the sidebar's and the console's do. html, not :root: the grammar
+ 1.x's new rules are held to has none (check/selectors_test.go). */
+ html:has(.rst-shell-topbar--page .rst-shell__up), html:has([rst-shell-topbar~="page"] [rst-shell-up]) { scroll-padding-block-start: var(--rst-shell-strip); }
+ /* The index's name is its title, which holds the brand; :not([hidden])
+ so shell.js can still hide one that does not fit. */
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__title:not([hidden]), [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-title]:not([hidden]) { align-items: center; display: flex; }
+ /* The rows hang from the bar's padding edge, so its border stays the
+ row's foot, and take the console index rail's padding. The foot is
+ anchored under them: it is the app's, and may hold links a reader
+ needs. */
+ .rst-shell-topbar--index:has(.rst-shell__up), [rst-shell-topbar~="index"]:has([rst-shell-up]) { position: relative; }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] { anchor-name: --rst-topbar-rows; box-sizing: border-box; flex-direction: column; gap: 0; inset-block-start: 100%; inset-inline: 0; padding: var(--rst-sp-5) var(--rst-sp-4); position: absolute; }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__foot, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-foot] { inset-block-start: anchor(--rst-topbar-rows end); inset-inline: 0; position: absolute; }
+ /* The rows are the sidebar's and the console's index rows, in rules
+ of their own: theirs are 1.3's, written without :has(), and a
+ :has() selector listed beside them would take them down with it
+ where :has() is not known. */
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a { align-items: center; background: var(--rst-surface); border: 1px solid var(--rst-line); border-block-start-width: 0; border-radius: 0; color: var(--rst-text); display: flex; font-size: 1rem; font-weight: 450; gap: var(--rst-sp-3); min-block-size: 3rem; padding-block: 0; padding-inline: 1rem 0.75rem; }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:first-child, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:first-child { border-block-start-width: 1px; border-start-end-radius: var(--rst-radius); border-start-start-radius: var(--rst-radius); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:last-child, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:last-child { border-end-end-radius: var(--rst-radius); border-end-start-radius: var(--rst-radius); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a::after, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a::after { block-size: 0.5rem; border-right: 2px solid var(--rst-text-faint); border-top: 2px solid var(--rst-text-faint); content: ""; flex: none; inline-size: 0.5rem; margin-inline-start: auto; transform: rotate(45deg); }
+ [dir="rtl"] .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a::after, [dir="rtl"] [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a::after { transform: rotate(-135deg); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:hover, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:hover { background: var(--rst-tint-hover, var(--rst-accent-soft)); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:active, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:active { background: var(--rst-tint-press, var(--rst-accent-soft)); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:focus-visible, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: -2px; }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:target, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:target { animation: rst-shell-flash 1.4s ease-out; }
+}
+/* An engine with no anchor positioning keeps the rows in the bar's
+ flow, under the row, and the foot under them: a taller bar, but
+ nothing out of reach. */
+@media (max-width: 799.98px) {
+ @supports not (anchor-name: --rst-topbar-rows) {
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] { block-size: auto; grid-template-rows: var(--rst-shell-strip); }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] { grid-column: 1 / -1; position: static; }
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__foot, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-foot] { position: static; }
+ }
+}
+@media (prefers-reduced-motion: reduce) {
+ .rst-shell-topbar--index:has(.rst-shell__up) > .rst-shell__bar > .rst-shell__nav > a:target, [rst-shell-topbar~="index"]:has([rst-shell-up]) > [rst-shell-bar] > [rst-shell-nav] > a:target { animation: none; }
+}
@keyframes rst-shell-flash { from { background: var(--rst-accent-soft); } }
@media (prefers-reduced-motion: reduce) {
.rst-shell-sidebar--index .rst-shell__nav > a:target, [rst-shell-sidebar~="index"] [rst-shell-nav] > a:target, .rst-shell-console--index .rst-shell__nav > a:target, [rst-shell-console~="index"] [rst-shell-nav] > a:target { animation: none; }
@@ -3426,6 +3750,78 @@ dialog.rst-modal-panel, dialog[rst-modal-panel] { block-size: auto; color: inher
it is not a hidden part of the link. */
.rst-signin__providers > a, [rst-signin-providers] > a { align-items: center; align-self: flex-start; box-sizing: border-box; display: inline-flex; min-block-size: var(--rst-target); min-inline-size: var(--rst-target); }
+/* ── The one-way door: one way in, and the rest behind a quiet control ─
+ rst-signin-door="one-way" is the door that offers a single way in
+ (the primary), then "Other ways to sign in", which opens the chooser
+ (rst-signin-ways). Every rule here needs that token or the chooser,
+ so the classic door above draws as it always has. The pill is the
+ door's, not every button's (Paul, 2026-11-19).
+
+ Every button on the door is a pill, lit from above (a white inner
+ top edge), at the lg step's height: on the door a button is the
+ page, not a toolbar control. The primary's shadow takes its own
+ fill's colour, deep in light and faint in dark, where a bright glow
+ would read as a halo. The press rules (0,4,0) outweigh these, so a
+ pill still sinks. An icon in a door button is 16px, as in any
+ control; a glyph that is not one of the icon set (a provider's own
+ mark, in currentColor) is 20px. */
+.rst-signin__door--one-way .rst-btn--block, [rst-signin-door~="one-way"] [rst-btn~="block"] { border-radius: 999px; font-size: var(--rst-fs-base); min-block-size: max(2.625rem, var(--rst-target)); padding-block: 0.5rem; }
+.rst-signin__door--one-way .rst-btn--primary, [rst-signin-door~="one-way"] [rst-btn~="primary"] { box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.22), 0 8px 18px -8px light-dark(color-mix(in srgb, var(--rst-accent-fill, var(--rst-accent)) 80%, transparent), color-mix(in srgb, var(--rst-accent-fill, var(--rst-accent)) 30%, transparent)); }
+.rst-signin__door--one-way .rst-btn > svg:not(.icon), [rst-signin-door~="one-way"] [rst-btn] > svg:not(.icon) { block-size: 1.25rem; flex: none; inline-size: 1.25rem; }
+/* What the door says under its button (the remembered address under
+ Keymail's one tap, the passkey's status line) is that button's
+ caption: centred under it, a step smaller. */
+.rst-signin__door--one-way .rst-signin__remembered, [rst-signin-door~="one-way"] [rst-signin-remembered], .rst-signin__door--one-way .rst-signin__passkey-msg, [rst-signin-door~="one-way"] [rst-signin-passkey-msg] { font-size: var(--rst-fs-sm); text-align: center; }
+
+/* The small controls are the door's ghosts: Other ways to sign in and
+ Back (links, children of the door) and Use a different email (the
+ button of a Forget form). They are text buttons a clear step below
+ the primary: medium weight, the muted ink that darkens on hover, a
+ touch smaller than body text, and a soft pill under them on hover
+ and focus. Semibold in full ink was tried and was too bold. The
+ focus ring is the page's 2px outline, which follows the pill. */
+.rst-signin__door--one-way .rst-btn--ghost, [rst-signin-door~="one-way"] [rst-btn~="ghost"] { align-self: center; border-radius: 999px; border-color: transparent; color: var(--rst-text-muted); font-size: calc(var(--rst-fs-base) * 0.9375); font-weight: 500; inline-size: auto; min-block-size: max(2.5rem, var(--rst-target)); padding: 0 0.875rem; }
+.rst-signin__door--one-way .rst-btn--ghost:hover, [rst-signin-door~="one-way"] [rst-btn~="ghost"]:hover, .rst-signin__door--one-way .rst-btn--ghost:focus-visible, [rst-signin-door~="one-way"] [rst-btn~="ghost"]:focus-visible { background-color: var(--rst-ghost-face-hover, var(--rst-surface-2)); color: var(--rst-text); }
+
+/* The chooser: one row per way, in a rounded box with hairlines
+ between the rows. A row is a link, or the button of a form (Use a
+ different email posts to Forget), so it keeps rst-btn for the busy
+ spinner and its press; here it is drawn as a row: no edge or fill of
+ its own, the row tint on hover, and a press that darkens in place
+ rather than dropping, since the box clips. 48px for one line,
+ border-box as every button is, so that is the row's height. The
+ glyph leads, one colour whatever the way, the name follows, then the
+ chevron, both glyphs in the muted ink. The leading glyph is 16px,
+ as an icon in any control is, a provider's own mark included, so
+ the names line up. The email row's second line
+ is the remembered address, the <bdi> in its name, at the row's start
+ edge whatever direction the address itself runs. The focus ring is
+ drawn inside the row, because the box clips at its corners. The
+ name is the row's <span>, never the busy spinner in either spelling:
+ busy.js puts a <span rst-spin aria-hidden="true"> first in the
+ button whichever spelling the page writes, so the rule passes over a
+ hidden span as well as its own spelling's spinner (a spinner is
+ always hidden; the name never is), which would otherwise grow to fill
+ the row where it is not centred over the label: under reduced
+ motion and forced colours. */
+.rst-signin__ways, [rst-signin-ways] { background: var(--rst-surface); border: 1px solid var(--rst-line); border-radius: var(--rst-radius); display: flex; flex-direction: column; overflow: hidden; }
+.rst-signin__ways .rst-btn, [rst-signin-ways] [rst-btn] { --rst-press-drop: 0px; background-color: transparent; border: 0; border-radius: 0; box-shadow: none; color: var(--rst-text); font-size: var(--rst-fs-base); font-weight: 550; gap: 0.75rem; justify-content: flex-start; min-block-size: 3rem; padding: 0.5625rem 0.875rem; text-align: start; }
+/* The hairline is on the row (a link) or its form, after the row rule,
+ which takes a row's own border away. */
+.rst-signin__ways > :not(:first-child), [rst-signin-ways] > :not(:first-child) { border-block-start: 1px solid var(--rst-line); }
+.rst-signin__ways .rst-btn:hover, [rst-signin-ways] [rst-btn]:hover { --rst-btn-sheen: none; background-color: var(--rst-row-tint-hover, var(--rst-surface-2)); color: var(--rst-text); }
+.rst-signin__ways .rst-btn:focus-visible, [rst-signin-ways] [rst-btn]:focus-visible { outline: 2px solid var(--rst-accent); outline-offset: -2px; }
+.rst-signin__ways .rst-btn > svg, [rst-signin-ways] [rst-btn] > svg { color: var(--rst-text-muted); }
+.rst-signin__ways .rst-btn > svg:first-child, [rst-signin-ways] [rst-btn] > svg:first-child { block-size: 1rem; flex: none; inline-size: 1rem; }
+.rst-signin__ways .rst-btn > span:not(.rst-spin, [aria-hidden]), [rst-signin-ways] [rst-btn] > span:not([rst-spin], [aria-hidden]) { display: grid; flex: 1; min-inline-size: 0; }
+.rst-signin__ways .rst-btn bdi, [rst-signin-ways] [rst-btn] bdi { color: var(--rst-text-muted); font-size: var(--rst-fs-sm); font-weight: 400; justify-self: start; }
+
+/* A chevron points the way the reader reads: onward toward the line's
+ end and Back toward its start, so in a right-to-left page both are
+ mirrored, as the pagination's are. A ghost on the door holds only a
+ chevron, and a chooser row's last glyph is its chevron. */
+[dir="rtl"] .rst-signin__door--one-way .rst-btn--ghost > svg, [dir="rtl"] [rst-signin-door~="one-way"] [rst-btn~="ghost"] > svg, [dir="rtl"] .rst-signin__ways .rst-btn > svg:last-child, [dir="rtl"] [rst-signin-ways] [rst-btn] > svg:last-child { transform: scaleX(-1); }
+
/* ── rst-stage: the stage shell (layouts/stage.html) ─────────────────
One card centred on a full-page backdrop. [rst-stage] is <body> in
the shell and a plain wrapper in the design-system gallery's frames,
diff --git a/internal/fichas/templates/signin.html b/internal/fichas/templates/signin.html
index c2bfadc..b80087f 100644
--- a/internal/fichas/templates/signin.html
+++ b/internal/fichas/templates/signin.html
@@ -6,31 +6,22 @@
<link rel="stylesheet" href="{{asset "static/chrome.css"}}">
{{end}}
-{{/* Every state is the suite's door (estilo chrome): one card on the sky,
- Fichas' mark and name at its head. Data: signinPage (handlers.go). */}}
+{{/* The Oficina door (signin.go): rastrillo's sign-in screen, its ui
+ "signin" partial fed by auth.SigninState, drawn inside estilo's door
+ (the sky, and Fichas' mark and name at the card's head) by
+ estilo-signin-screen. One way in per page (SigninOneWay): Fichas has
+ no Home, so the way is email, with "Use a different email" under it.
+ Every state is this one template: the door, Sent, the Keymail
+ continuation (its meta refresh is in the card), a problem, the
+ refusal, and the confirm step an emailed link opens (GET /auth/verify,
+ auth's RenderConfirm), whose one Sign in button POSTs the token back
+ because a GET must spend nothing. Its buttons are rastrillo's pills.
+
+ Or, with SignedOut set, where Sign out lands: the door's signed-out
+ page, with "Forget me on this device".
+
+ The plain layout has no account menu: every door is drawn signed out.
+ Data: signinPage (signin.go). */}}
{{define "content"}}
-{{with .Continue}}
- {{/* The keymail continuation. A document navigating is not the sign-in
- form's redirect chain, so form-action 'self' stays as strict as it
- was. The meta refresh needs no script; the link is the fallback. */}}
- <meta http-equiv="refresh" content="0;url={{.ContinueURL}}">
- {{template "estilo-door-open" .Door}}
- <h1>Continuing to keymail</h1>
- <p estilo-signin-body>Continuing to keymail to confirm it's you.</p>
- <p><a rst-btn="primary" href="{{.ContinueURL}}">Continue to keymail</a></p>
- {{template "estilo-door-close"}}
-{{else}}{{with .Confirm}}
- {{/* The emailed link's page: it spends nothing until this POST. */}}
- {{template "estilo-door-open" .Door}}
- <h1>{{.Heading}}</h1>
- <form rst-form method="post" action="{{.Action}}">
- <input type="hidden" name="token" value="{{.Token}}">
- <div rst-form-foot><button rst-btn="primary" type="submit" autofocus>{{.Submit}}</button></div>
- </form>
- {{template "estilo-door-close"}}
-{{else}}{{with .Sent}}
- {{template "estilo-signin-sent" .}}
-{{else}}
- {{template "estilo-signin" .Form}}
-{{end}}{{end}}{{end}}
+{{with .Screen}}{{template "estilo-signin-screen" .}}{{else}}{{with .SignedOut}}{{template "estilo-signed-out" .}}{{end}}{{end}}
{{end}}
diff --git a/internal/fichastest/account_test.go b/internal/fichastest/account_test.go
index 27273ea..69ca3fc 100644
--- a/internal/fichastest/account_test.go
+++ b/internal/fichastest/account_test.go
@@ -118,7 +118,7 @@ func TestAppearanceIsChosenInTheAccountMenu(t *testing.T) {
if len(cookies) != 1 || cookies[0].Value != "dark" {
t.Fatalf("POST /appearance set %v; want the dark preference", cookies)
}
- for _, path := range []string{"/", "/signin"} {
+ for _, path := range []string{"/", "/signin?sent=1", "/signed-out"} {
r := httptest.NewRequest(http.MethodGet, path, nil)
r.AddCookie(cookies[0])
rec := httptest.NewRecorder()
diff --git a/internal/fichastest/browser_edit_test.go b/internal/fichastest/browser_edit_test.go
index 052b6c3..19f99e9 100644
--- a/internal/fichastest/browser_edit_test.go
+++ b/internal/fichastest/browser_edit_test.go
@@ -267,6 +267,23 @@ func axeCheck(t *testing.T, rig *harness.Rig, path string, width int64, open str
// axeCheckWith is axeCheck with the page put in a state by before (a
// menu opened, say) once it has loaded.
func axeCheckWith(t *testing.T, rig *harness.Rig, path string, width int64, before ...chromedp.Action[chromedp.Void]) {
+ t.Helper()
+ steps := []chromedp.Action[chromedp.Void]{
+ send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
+ chromedp.Navigate(rig.Origin + path),
+ chromedp.WaitReady(`[fichas-main]`),
+ }
+ steps = append(steps, before...)
+ rig.Run(steps...)
+ for _, v := range axeHere(t, rig) {
+ t.Errorf("%s at %dpx: axe: %s", path, width, v)
+ }
+}
+
+// axeHere runs axe-core on the page the rig is on and returns its serious
+// and critical violations. axe-core comes from FICHAS_AXE, or the copy
+// the Ruby gem ships; a missing axe fails, since a skip is not a pass.
+func axeHere(t *testing.T, rig *harness.Rig) []string {
t.Helper()
src := os.Getenv("FICHAS_AXE")
if src == "" {
@@ -280,20 +297,11 @@ func axeCheckWith(t *testing.T, rig *harness.Rig, path string, width int64, befo
t.Fatalf("no axe-core (set FICHAS_AXE to axe.min.js): %v", err)
}
var found []string
- steps := []chromedp.Action[chromedp.Void]{
- send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
- chromedp.Navigate(rig.Origin + path),
- chromedp.WaitReady(`[fichas-main]`),
- }
- steps = append(steps, before...)
- steps = append(steps,
+ rig.Run(
chromedp.Evaluate[chromedp.Void](string(body)),
harness.Into(&found, chromedp.Evaluate[[]string](`axe.run(document, {resultTypes: ['violations']}).then(r => r.violations.filter(v => v.impact === 'serious' || v.impact === 'critical').map(v => v.id + ': ' + v.nodes.map(n => n.target.join(' ')).slice(0, 3).join(', ')))`, chromedp.EvalAwaitPromise)),
)
- rig.Run(steps...)
- for _, v := range found {
- t.Errorf("%s at %dpx: axe: %s", path, width, v)
- }
+ return found
}
// Mutations, 2026-11-17, each failing it: the sheet opened with show()
diff --git a/internal/fichastest/browser_test.go b/internal/fichastest/browser_test.go
index b1ae05f..4a9cdb9 100644
--- a/internal/fichastest/browser_test.go
+++ b/internal/fichastest/browser_test.go
@@ -197,7 +197,9 @@ func TestNoZoomOnTap(t *testing.T) {
// estilo's chrome, and the field every visit starts by tapping.
for _, page := range []struct{ path, ready string }{
{"/cards/new", `input[name="f_name"]`},
- {"/signin", `input[name="address"]`},
+ // A state of the door: AppForTest is signed in, and a bare /signin
+ // sends a signed-in browser on.
+ {"/signin?force=1", `input[name="address"]`},
// The list's search, and the type designer's forms.
{"/", `input[name="q"]`},
{"/cards/1", `textarea`},
@@ -438,3 +440,33 @@ func TestPrimaryButtonsAreFilled(t *testing.T) {
}
}
}
+
+// TestTheViewTabsSitInTheToolbarsRow: rastrillo puts a margin under a
+// block of tabs, and in the list's toolbar row it only pushed the row
+// apart and lifted the tabs off its centre line (Calendar's 18px gap,
+// oficina/calendar #48). Mutation: deleting the fichas.css rule fails it.
+func TestTheViewTabsSitInTheToolbarsRow(t *testing.T) {
+ rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
+ m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
+ fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
+ map[string]string{fichas.FieldName: "Brightwater Labs"})
+ })
+ var margin string
+ var offset float64
+ rig.Run(
+ chromedp.Navigate(rig.Origin+"/?view=cards"),
+ chromedp.WaitVisible(`[fichas-toolbar] [rst-seg-tabs]`),
+ harness.Into(&margin, chromedp.Evaluate[string](`getComputedStyle(document.querySelector('[fichas-toolbar] > [rst-seg-tabs]')).marginBlockEnd`)),
+ harness.Into(&offset, chromedp.Evaluate[float64](`(() => {
+ const bar = document.querySelector('[fichas-toolbar]').getBoundingClientRect();
+ const tabs = document.querySelector('[fichas-toolbar] > [rst-seg-tabs]').getBoundingClientRect();
+ return Math.abs((tabs.top + tabs.bottom) / 2 - (bar.top + bar.bottom) / 2);
+ })()`)),
+ )
+ if margin != "0px" {
+ t.Errorf("the view tabs keep a %s margin under them in the toolbar row", margin)
+ }
+ if offset > 1 {
+ t.Errorf("the view tabs sit %.1fpx off the toolbar's centre line", offset)
+ }
+}
diff --git a/internal/fichastest/contract_test.go b/internal/fichastest/contract_test.go
index f6d338a..e56a8b1 100644
--- a/internal/fichastest/contract_test.go
+++ b/internal/fichastest/contract_test.go
@@ -38,7 +38,7 @@ func TestContractReleaseThroughRealAdmission(t *testing.T) {
t.Fatal(e)
}
m := &capturingMailer{}
- au, e := fichas.NewAuth(d.Writer(), fichas.AuthEnv{Origin: cfg.Origin, InstanceKey: cfg.InstanceKey, Mailer: m}, logger, app.Admit)
+ au, e := fichas.NewAuth(d.Writer(), fichas.AuthEnv{Origin: cfg.Origin, InstanceKey: cfg.InstanceKey, Mailer: m}, logger, app)
if e != nil {
t.Fatal(e)
}
diff --git a/internal/fichastest/signin_door_browser_test.go b/internal/fichastest/signin_door_browser_test.go
new file mode 100644
index 0000000..b36e51e
--- /dev/null
+++ b/internal/fichastest/signin_door_browser_test.go
@@ -0,0 +1,162 @@
+//go:build browser
+
+package fichastest
+
+// The smart door in a real Chromium, forced to light: every state at 320
+// and 1280px with no sideways scroll, every control a 24px target at
+// least, nothing serious or critical to axe, and the refusal drawn for a
+// session the owners list no longer holds.
+
+import (
+ "context"
+ "encoding/base64"
+ "io"
+ "log/slog"
+ "net/http"
+ "net/http/httptest"
+ "path/filepath"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/db"
+ "amadan.net/rastrillo/rastrillo/harness"
+ "amadan.net/rastrillo/rastrillo/sessions"
+ "github.com/chromedp/cdproto/cdp"
+ "github.com/chromedp/cdproto/emulation"
+ "github.com/chromedp/cdproto/network"
+ "github.com/chromedp/chromedp"
+
+ fichas "amadan.net/oficina/fichas/internal/fichas"
+)
+
+// doorRig is the app as main.go wires it (real sign-in, no test identity),
+// and a session for TestOther, who is not an owner: the cookie value the
+// refusal state presents.
+func doorRig(t *testing.T) (*harness.Rig, string) {
+ var refused string
+ rig := harness.New(t, func(origin string) http.Handler {
+ logger := slog.New(slog.NewTextHandler(io.Discard, nil))
+ d, err := db.Open(filepath.Join(t.TempDir(), "app.db"), logger)
+ if err != nil {
+ t.Fatalf("db.Open: %v", err)
+ }
+ t.Cleanup(func() { d.Close() })
+ cfg, err := fichas.LoadConfig(func(k string) string {
+ return map[string]string{
+ "FICHAS_DEK": base64.StdEncoding.EncodeToString(testKey()),
+ "FICHAS_INSTANCE_KEY": "browser",
+ "FICHAS_OWNERS": TestOwner,
+ "FICHAS_ORIGIN": origin,
+ "FICHAS_ALLOW_LOGGED_MAIL": "1",
+ }[k]
+ })
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ mux, app, err := fichas.App(d, cfg, logger)
+ if err != nil {
+ t.Fatalf("App: %v", err)
+ }
+ au, err := fichas.NewAuth(d.Writer(), fichas.AuthEnv{Origin: cfg.Origin, InstanceKey: cfg.InstanceKey, Mailer: &capturingMailer{}}, logger, app)
+ if err != nil {
+ t.Fatalf("NewAuth: %v", err)
+ }
+ app.UseAuth(au)
+ core, err := sessions.New(sessions.Config{DB: d.Writer(), Origin: origin})
+ if err != nil {
+ t.Fatal(err)
+ }
+ w := httptest.NewRecorder()
+ if err := core.SignIn(w, httptest.NewRequest(http.MethodGet, "/", nil), sessions.Session{Subject: TestOther, Method: "magiclink", AuthTime: time.Now()}); err != nil {
+ t.Fatal(err)
+ }
+ for _, c := range w.Result().Cookies() {
+ if c.Name == core.CookieName() {
+ refused = c.Value
+ }
+ }
+ return mux
+ })
+ return rig, refused
+}
+
+func TestSmartDoorInABrowser(t *testing.T) {
+ states := []struct {
+ name, path string
+ refused bool
+ }{
+ {"field", "/signin", false},
+ {"rate", "/signin?err=rate", false},
+ {"address", "/signin?err=address", false},
+ {"keymail", "/signin?err=keymail&force=1", false},
+ {"expired", "/signin?err=expired", false},
+ {"generic", "/signin?err=1", false},
+ {"reauth", "/signin?reauth=1", false},
+ {"sent", "/signin?sent=1", false},
+ {"confirm", "/auth/verify?token=" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", false},
+ {"signed-out", "/signed-out", false},
+ {"refusal", "/signin", true},
+ }
+ for _, width := range []int64{320, 1280} {
+ for _, st := range states {
+ rig, refused := doorRig(t)
+ var facts struct {
+ Scroll, Inner float64
+ Small []string
+ Refusal, Door bool
+ }
+ steps := []chromedp.Action[chromedp.Void]{
+ send(emulation.SetEmulatedMedia, emulation.SetEmulatedMediaParams{Features: []*emulation.MediaFeature{{Name: "prefers-color-scheme", Value: "light"}}}),
+ viewport(width),
+ }
+ if st.refused {
+ steps = append(steps, chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: "rastrillo_session", Value: refused, URL: rig.Origin + "/"})
+ return err
+ }))
+ }
+ steps = append(steps,
+ chromedp.Navigate(rig.Origin+st.path),
+ chromedp.WaitVisible(`[estilo-signin]`),
+ harness.Into(&facts, chromedp.Evaluate[struct {
+ Scroll, Inner float64
+ Small []string
+ Refusal, Door bool
+ }](`({
+ Scroll: document.documentElement.scrollWidth,
+ Inner: innerWidth,
+ Small: [...document.querySelectorAll('[estilo-signin] :is(a, button, input:not([type=hidden]))')]
+ .filter(e => e.offsetParent !== null)
+ .filter(e => { const r = e.getBoundingClientRect(); return r.height < 24 || r.width < 24 })
+ .map(e => e.outerHTML.slice(0, 80)),
+ Refusal: document.body.textContent.includes('can’t sign in to Fichas'),
+ Door: !!document.querySelector('[estilo-door]'),
+ })`)),
+ )
+ rig.Run(steps...)
+ if !facts.Door {
+ t.Errorf("%s at %d: not the door", st.name, width)
+ }
+ if facts.Scroll > facts.Inner {
+ t.Errorf("%s at %d: scrolls sideways (%.0f > %.0f)", st.name, width, facts.Scroll, facts.Inner)
+ }
+ for _, s := range facts.Small {
+ t.Errorf("%s at %d: a target under 24px: %s", st.name, width, s)
+ }
+ if facts.Refusal != st.refused {
+ t.Errorf("%s at %d: refusal drawn %v, want %v", st.name, width, facts.Refusal, st.refused)
+ }
+ axeDoor(t, rig, width)
+ }
+ }
+}
+
+// axeDoor runs axe on the page the rig is on, as axeCheckWith does for
+// the app's own pages.
+func axeDoor(t *testing.T, rig *harness.Rig, width int64) {
+ t.Helper()
+ found := axeHere(t, rig)
+ for _, v := range found {
+ t.Errorf("door at %dpx: axe: %s", width, v)
+ }
+}
diff --git a/internal/fichastest/signin_door_helpers_test.go b/internal/fichastest/signin_door_helpers_test.go
new file mode 100644
index 0000000..4558e26
--- /dev/null
+++ b/internal/fichastest/signin_door_helpers_test.go
@@ -0,0 +1,189 @@
+package fichastest
+
+// Helpers for the smart door's tests (signin_door_*_test.go): a browser's
+// cookie jar over httptest, a sign-in walked the way a person walks it,
+// and a second app over the same database with a different owners list,
+// which is how a session or a link for an address taken off FICHAS_OWNERS
+// is made from the outside.
+
+import (
+ "io"
+ "log/slog"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "path/filepath"
+ "regexp"
+ "strings"
+ "testing"
+
+ fichas "amadan.net/oficina/fichas/internal/fichas"
+ "amadan.net/rastrillo/rastrillo/db"
+)
+
+// TestOther is a second address, an owner of the wider instance only.
+const TestOther = "bo@example.com"
+
+// browser is a cookie jar: what a browser would send back.
+type browser struct {
+ cookies map[string]*http.Cookie
+}
+
+func newBrowser() *browser { return &browser{cookies: map[string]*http.Cookie{}} }
+
+// keep applies a response's Set-Cookie headers as a browser would.
+func (b *browser) keep(rec *httptest.ResponseRecorder) {
+ for _, c := range rec.Result().Cookies() {
+ if c.MaxAge < 0 || c.Value == "" {
+ delete(b.cookies, c.Name)
+ continue
+ }
+ b.cookies[c.Name] = c
+ }
+}
+
+func (b *browser) has(name string) bool { _, ok := b.cookies[name]; return ok }
+
+func (b *browser) send(req *http.Request) {
+ for _, c := range b.cookies {
+ req.AddCookie(&http.Cookie{Name: c.Name, Value: c.Value})
+ }
+}
+
+func (b *browser) get(t *testing.T, h http.Handler, target string) *httptest.ResponseRecorder {
+ t.Helper()
+ req := httptest.NewRequest(http.MethodGet, target, nil)
+ b.send(req)
+ rec := httptest.NewRecorder()
+ h.ServeHTTP(rec, req)
+ b.keep(rec)
+ return rec
+}
+
+func (b *browser) post(t *testing.T, h http.Handler, target string, form url.Values) *httptest.ResponseRecorder {
+ t.Helper()
+ return b.postRaw(t, h, target, form.Encode())
+}
+
+// postRaw posts body as it is, so a test can send one that does not parse.
+func (b *browser) postRaw(t *testing.T, h http.Handler, target, body string) *httptest.ResponseRecorder {
+ t.Helper()
+ req := httptest.NewRequest(http.MethodPost, target, strings.NewReader(body))
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Set("Origin", testOrigin)
+ b.send(req)
+ rec := httptest.NewRecorder()
+ h.ServeHTTP(rec, req)
+ b.keep(rec)
+ return rec
+}
+
+// crossSitePost is a form post from another site, carrying b's cookies.
+func crossSitePost(t *testing.T, h http.Handler, b *browser, target string) *httptest.ResponseRecorder {
+ t.Helper()
+ req := httptest.NewRequest(http.MethodPost, target, strings.NewReader(""))
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ req.Header.Set("Origin", "https://evil.example")
+ req.Header.Set("Sec-Fetch-Site", "cross-site")
+ b.send(req)
+ rec := httptest.NewRecorder()
+ h.ServeHTTP(rec, req)
+ b.keep(rec)
+ return rec
+}
+
+// getWith is a GET carrying cookies.
+func getWith(t *testing.T, h http.Handler, target string, cookies []*http.Cookie) *httptest.ResponseRecorder {
+ t.Helper()
+ req := httptest.NewRequest(http.MethodGet, target, nil)
+ for _, c := range cookies {
+ req.AddCookie(c)
+ }
+ rec := httptest.NewRecorder()
+ h.ServeHTTP(rec, req)
+ return rec
+}
+
+// cookie names, as auth names them on testOrigin (http, so no __Host-).
+const (
+ sessionCookie = "rastrillo_session"
+ returnCookie = "rastrillo_return_to"
+ rememberName = "rastrillo_last_signin"
+)
+
+// sharedApps is two apps over one database, as main.go wires them, with
+// the same keys: wide admits TestOwner and TestOther, narrow TestOwner
+// only. A link sent by wide and opened on narrow, or a session minted by
+// wide and presented to narrow, is an address taken off the owners list.
+func sharedApps(t *testing.T) (wide, narrow http.Handler, mailer *capturingMailer, d *db.DB) {
+ t.Helper()
+ logger := slog.New(slog.NewTextHandler(io.Discard, nil))
+ d, err := db.Open(filepath.Join(t.TempDir(), "app.db"), logger)
+ if err != nil {
+ t.Fatalf("db.Open: %v", err)
+ }
+ t.Cleanup(func() { d.Close() })
+ mailer = &capturingMailer{}
+ build := func(owners ...string) http.Handler {
+ cfg := testConfig(t)
+ cfg.Owners = owners
+ mux, app, err := fichas.App(d, cfg, logger)
+ if err != nil {
+ t.Fatalf("App: %v", err)
+ }
+ au, err := fichas.NewAuth(d.Writer(), fichas.AuthEnv{Origin: cfg.Origin, InstanceKey: cfg.InstanceKey, Mailer: mailer}, logger, app)
+ if err != nil {
+ t.Fatalf("NewAuth: %v", err)
+ }
+ app.UseAuth(au)
+ return mux
+ }
+ return build(TestOwner, TestOther), build(TestOwner), mailer, d
+}
+
+// linkFor asks h for a link to address (force=1: no classifier, no dial)
+// and returns the emailed token.
+func linkFor(t *testing.T, h http.Handler, b *browser, m *capturingMailer, address string, extra url.Values) string {
+ t.Helper()
+ form := url.Values{"address": {address}, "force": {"1"}}
+ for k, v := range extra {
+ form[k] = v
+ }
+ rec := b.post(t, h, "/auth/begin", form)
+ if rec.Code != http.StatusSeeOther || !strings.HasPrefix(rec.Header().Get("Location"), "/signin?sent=1&attempt=") {
+ t.Fatalf("POST /auth/begin: %d %q", rec.Code, rec.Header().Get("Location"))
+ }
+ mail := m.last(t)
+ if !strings.HasPrefix(mail, address+"\n") {
+ t.Fatalf("the last mail went elsewhere:\n%s", mail)
+ }
+ match := linkToken.FindStringSubmatch(mail)
+ if match == nil {
+ t.Fatalf("no link in:\n%s", mail)
+ }
+ tok, err := url.QueryUnescape(match[1])
+ if err != nil {
+ t.Fatal(err)
+ }
+ return tok
+}
+
+// signIn walks the email path in b on h, link to landing, and returns the
+// landing's answer.
+func signIn(t *testing.T, h http.Handler, b *browser, m *capturingMailer, address string, extra url.Values) *httptest.ResponseRecorder {
+ t.Helper()
+ tok := linkFor(t, h, b, m, address, extra)
+ return b.post(t, h, "/auth/verify", url.Values{"token": {tok}})
+}
+
+var titleRE = regexp.MustCompile(`<title>([^<]*)</title>`)
+
+func titleOf(body string) string {
+ if m := titleRE.FindStringSubmatch(body); m != nil {
+ return m[1]
+ }
+ return ""
+}
+
+// refusalText is the refusal, as html/template writes it.
+const refusalText = "That email can’t sign in to Fichas. Use a different email, or ask whoever runs this team to add it."
diff --git a/internal/fichastest/signin_door_refusal_test.go b/internal/fichastest/signin_door_refusal_test.go
new file mode 100644
index 0000000..7bdeda0
--- /dev/null
+++ b/internal/fichastest/signin_door_refusal_test.go
@@ -0,0 +1,174 @@
+package fichastest
+
+// The refusal, and a session the signed-in routes no longer admit
+// (an address taken off FICHAS_OWNERS): ended at the door, refused on the
+// plain door only, never judged when it is not a web sign-in, and never
+// refused because something could not be read.
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/sessions"
+)
+
+// A link proved for an address the owners list does not hold gets the
+// door with the refusal, in a 403, with the email field: no session, no
+// remembered way, and the kept page spent.
+func TestARefusedLinkGetsTheRefusal(t *testing.T) {
+ wide, narrow, m, _ := sharedApps(t)
+ b := newBrowser()
+ tok := linkFor(t, wide, b, m, TestOther, url.Values{"return_to": {"/cards/new"}})
+ if !b.has(returnCookie) {
+ t.Fatal("Begin kept no page")
+ }
+ rec := b.post(t, narrow, "/auth/verify", url.Values{"token": {tok}})
+ if rec.Code != http.StatusForbidden {
+ t.Fatalf("a refused verify: %d, want 403", rec.Code)
+ }
+ body := rec.Body.String()
+ for _, want := range []string{refusalText, `name="address"`, "<div estilo-signin-screen>", `<div rst-signin-door="one-way">`} {
+ if !strings.Contains(body, want) {
+ t.Errorf("the refusal lacks %q:\n%s", want, body)
+ }
+ }
+ if b.has(sessionCookie) {
+ t.Error("a refused address was given a session")
+ }
+ if b.has(rememberName) {
+ t.Error("a refused address was remembered")
+ }
+ if b.has(returnCookie) {
+ t.Error("a refused landing kept the page: every landing spends it")
+ }
+ // Typed into the query, it says nothing: only a proved refusal does.
+ if strings.Contains(get(t, narrow, "/signin?err=refused").Body.String(), refusalText) {
+ t.Error("?err=refused typed in draws the refusal")
+ }
+}
+
+// A session for an address taken off the owners list: the page refuses
+// it (404), and the door ends it there and then, says why on the plain
+// door, clears its cookie on the same response, and does not loop.
+func TestARefusedSessionIsEndedAtTheDoor(t *testing.T) {
+ wide, narrow, m, _ := sharedApps(t)
+ b := newBrowser()
+ if rec := signIn(t, wide, b, m, TestOther, nil); rec.Code != http.StatusSeeOther {
+ t.Fatalf("sign in on the wide app: %d", rec.Code)
+ }
+ if rec := b.get(t, narrow, "/"); rec.Code != http.StatusNotFound {
+ t.Fatalf("the narrow app's page answered %d, want its 404 refusal", rec.Code)
+ }
+ if !b.has(sessionCookie) {
+ t.Fatal("the page ended the session itself: removal belongs to the door")
+ }
+ old := b.cookies[sessionCookie]
+ door := b.get(t, narrow, "/signin")
+ if door.Code != http.StatusOK {
+ t.Fatalf("GET /signin: %d", door.Code)
+ }
+ if !strings.Contains(door.Body.String(), refusalText) || !strings.Contains(door.Body.String(), `name="address"`) {
+ t.Errorf("the door does not say why, with the field:\n%s", door.Body.String())
+ }
+ if b.has(sessionCookie) {
+ t.Error("the refused session's cookie was not cleared on the door's response")
+ }
+ if door.Header().Get("Cache-Control") != "no-store" {
+ t.Error("the refusal is cacheable")
+ }
+ // Ended, not just forgotten by this browser: the old cookie is dead
+ // on the app that minted it too.
+ if rec := getWith(t, wide, "/", []*http.Cookie{{Name: old.Name, Value: old.Value}}); rec.Code != http.StatusSeeOther {
+ t.Errorf("the ended session still opens the wide app: %d", rec.Code)
+ }
+ // The remembered email way is kept: offered again, Begin refuses it.
+ if !b.has(rememberName) {
+ t.Error("the refusal forgot the email way")
+ }
+ // A reload is plainly signed out: no refusal, no loop.
+ again := b.get(t, narrow, "/signin")
+ if again.Code != http.StatusOK || strings.Contains(again.Body.String(), refusalText) {
+ t.Errorf("reload: %d, refusal drawn again: %v", again.Code, strings.Contains(again.Body.String(), refusalText))
+ }
+}
+
+// The refusal is on the plain door only: the chooser and a way's own page
+// are how a refused person reaches another way in. Every state still
+// ends the refused session. Sent and a problem of rastrillo's own draw no
+// app problem: rastrillo's state wins there (as Calendar found).
+func TestTheRefusalIsOnlyOnThePlainDoor(t *testing.T) {
+ for target, refusal := range map[string]bool{
+ "/signin?ways=1": false,
+ "/signin?way=email": false,
+ "/signin?sent=1": false,
+ "/signin?err=expired": false,
+ "/signin?reauth=1": true,
+ "/signin?force=1": true,
+ } {
+ wide, narrow, m, _ := sharedApps(t)
+ b := newBrowser()
+ signIn(t, wide, b, m, TestOther, nil)
+ rec := b.get(t, narrow, target)
+ if rec.Code != http.StatusOK {
+ t.Errorf("%s: %d", target, rec.Code)
+ }
+ if got := strings.Contains(rec.Body.String(), refusalText); got != refusal {
+ t.Errorf("%s: refusal drawn %v, want %v", target, got, refusal)
+ }
+ if b.has(sessionCookie) {
+ t.Errorf("%s: the refused session was not ended", target)
+ }
+ }
+}
+
+// The door judges web sign-ins only (an emailed link, Keymail). A session
+// of any other kind is not the door's to speak for: it is drawn the door
+// as anybody signed out, and is never refused or ended.
+func TestTheDoorJudgesWebSessionsOnly(t *testing.T) {
+ _, narrow, _, d := sharedApps(t)
+ core, err := sessions.New(sessions.Config{DB: d.Writer(), Origin: testOrigin})
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, method := range []string{"home-assertion-native", "passkey", "guest"} {
+ w := httptest.NewRecorder()
+ if err := core.SignIn(w, httptest.NewRequest(http.MethodGet, "/", nil), sessions.Session{Subject: TestOther, Method: method, AuthTime: time.Now()}); err != nil {
+ t.Fatal(err)
+ }
+ b := newBrowser()
+ b.keep(w)
+ rec := b.get(t, narrow, "/signin")
+ if rec.Code != http.StatusOK || strings.Contains(rec.Body.String(), refusalText) {
+ t.Errorf("%s: %d, refusal %v; want the plain door", method, rec.Code, strings.Contains(rec.Body.String(), refusalText))
+ }
+ if !b.has(sessionCookie) {
+ t.Errorf("%s: the door ended a session it does not judge", method)
+ }
+ }
+}
+
+// A session store that cannot be read is no refusal: the door is drawn,
+// nothing is refused, remembered or forgotten, and the cookie is kept.
+func TestAnUnreadableSessionIsNoRefusal(t *testing.T) {
+ h, m, d := wiredApp(t)
+ b := newBrowser()
+ signIn(t, h, b, m, TestOwner, nil)
+ if err := d.G.Exec("DROP TABLE sessions").Error; err != nil {
+ t.Fatal(err)
+ }
+ rec := b.get(t, h, "/signin")
+ if rec.Code != http.StatusOK || strings.Contains(rec.Body.String(), refusalText) {
+ t.Errorf("GET /signin: %d, refusal %v", rec.Code, strings.Contains(rec.Body.String(), refusalText))
+ }
+ if !b.has(sessionCookie) || !b.has(rememberName) {
+ t.Error("a read failure cleared the session or the remembered way")
+ }
+ // The page is not answered as "not here" either.
+ if page := b.get(t, h, "/"); page.Code == http.StatusNotFound {
+ t.Error("a read failure was answered as a refusal")
+ }
+}
diff --git a/internal/fichastest/signin_door_return_test.go b/internal/fichastest/signin_door_return_test.go
new file mode 100644
index 0000000..824a533
--- /dev/null
+++ b/internal/fichastest/signin_door_return_test.go
@@ -0,0 +1,129 @@
+package fichastest
+
+// The return memory: the page a sign-in began from, kept across the mail
+// round trip, landed on once, and never kept when it should not be
+// (signin.go's beginReturn and forget; rastrillo's keepReturnTo, admit
+// and Signout).
+
+import (
+ "net/http"
+ "net/url"
+ "strings"
+ "testing"
+)
+
+// A signed-out page request goes to the door with the page; the door's
+// form carries it; the landing goes there, and spends it.
+func TestTheKeptPageIsLandedOn(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ first := b.get(t, h, "/cards/new")
+ if first.Code != http.StatusSeeOther || first.Header().Get("Location") != "/signin?return_to=%2Fcards%2Fnew" {
+ t.Fatalf("signed-out GET /cards/new: %d to %q", first.Code, first.Header().Get("Location"))
+ }
+ door := b.get(t, h, first.Header().Get("Location")).Body.String()
+ if !strings.Contains(door, `<input type="hidden" name="return_to" value="/cards/new">`) {
+ t.Fatalf("the door's form does not carry the page:\n%s", door)
+ }
+ landing := signIn(t, h, b, m, TestOwner, url.Values{"return_to": {"/cards/new"}})
+ if landing.Header().Get("Location") != "/cards/new" {
+ t.Errorf("landed on %q, want /cards/new", landing.Header().Get("Location"))
+ }
+ if b.has(returnCookie) {
+ t.Error("the landing did not spend the kept page")
+ }
+}
+
+// Every landing that mints a session spends the kept page, so a second
+// landing goes to the list, not to the first one's page.
+func TestEveryLandingSpendsTheKeptPage(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ plain := linkFor(t, h, b, m, TestOwner, nil)
+ kept := linkFor(t, h, b, m, TestOwner, url.Values{"return_to": {"/cards/new"}})
+ if rec := b.post(t, h, "/auth/verify", url.Values{"token": {plain}}); rec.Header().Get("Location") != "/cards/new" {
+ t.Fatalf("first landing: %q", rec.Header().Get("Location"))
+ }
+ if rec := b.post(t, h, "/auth/verify", url.Values{"token": {kept}}); rec.Header().Get("Location") != "/" {
+ t.Errorf("second landing went to %q, want /: the page was not spent", rec.Header().Get("Location"))
+ }
+}
+
+// A post without return_to forgets a page an earlier, abandoned attempt
+// kept, owner and stranger alike.
+func TestAPostWithoutAPageForgetsTheKeptOne(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ for _, address := range []string{TestOwner, "zzz@example.com"} {
+ b := newBrowser()
+ b.post(t, h, "/auth/begin", url.Values{"address": {address}, "force": {"1"}, "return_to": {"/cards/new"}})
+ if !b.has(returnCookie) {
+ t.Fatalf("%s: Begin kept no page", address)
+ }
+ b.post(t, h, "/auth/begin", url.Values{"address": {address}, "force": {"1"}})
+ if b.has(returnCookie) {
+ t.Errorf("%s: a post without return_to kept the earlier page", address)
+ }
+ }
+ b := newBrowser()
+ b.post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}, "return_to": {"/cards/new"}})
+ if rec := signIn(t, h, b, m, TestOwner, nil); rec.Header().Get("Location") != "/" {
+ t.Errorf("landed on %q, want /", rec.Header().Get("Location"))
+ }
+}
+
+// A body that does not parse keeps nothing, even what parsed before the
+// error, and forgets what was kept.
+func TestABodyThatDoesNotParseKeepsNoPage(t *testing.T) {
+ h, _, _ := wiredApp(t)
+ b := newBrowser()
+ b.post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}, "return_to": {"/t/x"}})
+ rec := b.postRaw(t, h, "/auth/begin", "address="+url.QueryEscape(TestOwner)+"&force=1&return_to=%2Fcards%2Fnew&bad=%zz")
+ if rec.Code != http.StatusSeeOther {
+ t.Fatalf("POST: %d", rec.Code)
+ }
+ if b.has(returnCookie) {
+ t.Errorf("a body that did not parse kept %q", b.cookies[returnCookie].Value)
+ }
+ if strings.Contains(rec.Header().Get("Location"), "return_to") {
+ t.Errorf("the answer carries a page: %q", rec.Header().Get("Location"))
+ }
+}
+
+// A page that is no page to come back to is never kept: the signed-out
+// page, the door, auth's routes, another site. The door drops it from its
+// form, Begin keeps nothing, and the landing is the list.
+func TestNoPageThatIsNoPageIsKept(t *testing.T) {
+ for _, to := range []string{"/signed-out", "/signed-out?x=1", "/signin", "/signin/forget", "/auth/verify", "//evil.example/x", "https://evil.example/", "/\\evil.example"} {
+ // A fresh app each time: the per-address budget is five.
+ h, m, _ := wiredApp(t)
+ door := get(t, h, "/signin?return_to="+url.QueryEscape(to)).Body.String()
+ if strings.Contains(door, `name="return_to"`) {
+ t.Errorf("%q: the door's form carries it", to)
+ }
+ b := newBrowser()
+ rec := signIn(t, h, b, m, TestOwner, url.Values{"return_to": {to}})
+ if rec.Header().Get("Location") != "/" {
+ t.Errorf("%q: landed on %q, want /", to, rec.Header().Get("Location"))
+ }
+ }
+}
+
+// Forget and Sign out clear a kept page: on a shared computer it is the
+// last person's, not the next one's.
+func TestForgetAndSignOutClearTheKeptPage(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ b.post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}, "return_to": {"/cards/new"}})
+ b.post(t, h, "/signin/forget", url.Values{"return_to": {"/cards/new"}})
+ if b.has(returnCookie) {
+ t.Error("Forget kept the page")
+ }
+
+ b = newBrowser()
+ signIn(t, h, b, m, TestOwner, nil)
+ b.post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}, "return_to": {"/cards/new"}})
+ b.post(t, h, "/signout", url.Values{})
+ if b.has(returnCookie) {
+ t.Error("Sign out kept the page")
+ }
+}
diff --git a/internal/fichastest/signin_door_states_test.go b/internal/fichastest/signin_door_states_test.go
new file mode 100644
index 0000000..b4d3cb3
--- /dev/null
+++ b/internal/fichastest/signin_door_states_test.go
@@ -0,0 +1,255 @@
+package fichastest
+
+// The smart door's routes and states (Home spec 2026-11-19-smart-door.md,
+// step 6). Fichas has no Home: email is the one way in.
+
+import (
+ "net/http"
+ "net/url"
+ "strings"
+ "testing"
+)
+
+// Every route the door answers, and the two a Home-derived app mounts
+// that Fichas does not.
+func TestTheDoorsRoutes(t *testing.T) {
+ h, _, _ := wiredApp(t)
+ for path, want := range map[string]int{
+ "/signin": http.StatusOK,
+ "/signed-out": http.StatusOK,
+ "/signin/local": http.StatusNotFound,
+ "/signin/oficina": http.StatusNotFound,
+ } {
+ rec := get(t, h, path)
+ if rec.Code != want {
+ t.Errorf("GET %s: %d, want %d", path, rec.Code, want)
+ }
+ if want == http.StatusOK && rec.Header().Get("Cache-Control") != "no-store" {
+ t.Errorf("GET %s: Cache-Control %q, want no-store", path, rec.Header().Get("Cache-Control"))
+ }
+ }
+}
+
+// Each state of the door, signed out, with its tab title, which is what
+// its heading says.
+func TestEveryDoorStateHasItsTitle(t *testing.T) {
+ h, _, _ := wiredApp(t)
+ for path, title := range map[string]string{
+ "/signin": "Sign in to Fichas",
+ "/signin?err=rate": "Problem signing in to Fichas",
+ "/signin?err=address": "Problem signing in to Fichas",
+ "/signin?err=expired": "Problem signing in to Fichas",
+ "/signin?err=keymail&force=1": "Problem signing in to Fichas",
+ "/signin?err=1": "Problem signing in to Fichas",
+ "/signin?continue=nothing": "Problem signing in to Fichas",
+ "/signin?reauth=1": "Sign in to Fichas",
+ "/signin?force=1": "Sign in to Fichas",
+ "/signed-out": "Signed out · Fichas",
+ } {
+ rec := get(t, h, path)
+ if rec.Code != http.StatusOK {
+ t.Errorf("GET %s: %d", path, rec.Code)
+ continue
+ }
+ body := rec.Body.String()
+ if got := titleOf(body); got != title {
+ t.Errorf("GET %s: title %q, want %q", path, got, title)
+ }
+ if !strings.Contains(body, "estilo-door") || !strings.Contains(body, "<span>Fichas</span>") {
+ t.Errorf("GET %s is not the door", path)
+ }
+ if strings.Contains(body, "Oficina ID") {
+ t.Errorf("GET %s offers Oficina ID", path)
+ }
+ }
+ // A failed Keymail round trip keeps the plain-email choice it offered.
+ if body := get(t, h, "/signin?err=keymail&force=1").Body.String(); !strings.Contains(body, `<input type="hidden" name="force" value="1">`) {
+ t.Error("after a Keymail failure the door does not keep force=1")
+ }
+ // A step-up keeps reauth on the post.
+ if body := get(t, h, "/signin?reauth=1").Body.String(); !strings.Contains(body, `<input type="hidden" name="reauth" value="1">`) {
+ t.Error("a step-up's door does not post reauth=1")
+ }
+}
+
+// Signed in and admitted, a bare /signin is no door: it goes back to the
+// page asked for, or the list, and never to a page that is no page.
+func TestASignedInOwnerIsSentOn(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ signIn(t, h, b, m, TestOwner, nil)
+ for target, want := range map[string]string{
+ "/signin": "/",
+ "/signin?return_to=%2Fcards%2Fnew": "/cards/new",
+ "/signin?return_to=%2Fsigned-out": "/",
+ "/signin?return_to=%2F%2Fevil.example%2F": "/",
+ "/signin?return_to=https%3A%2F%2Fevil.example%2F": "/",
+ "/signin?return_to=%2Fa&return_to=%2Fb": "/",
+ } {
+ rec := b.get(t, h, target)
+ if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != want {
+ t.Errorf("GET %s signed in: %d to %q, want 303 to %q", target, rec.Code, rec.Header().Get("Location"), want)
+ }
+ }
+ // A state of the door is drawn for a signed-in browser too, and every
+ // door is drawn signed out: no account menu, no address.
+ for _, target := range []string{"/signin?sent=1", "/signin?err=expired", "/signin?reauth=1", "/signed-out"} {
+ rec := b.get(t, h, target)
+ body := rec.Body.String()
+ if rec.Code != http.StatusOK {
+ t.Errorf("GET %s signed in: %d", target, rec.Code)
+ }
+ for _, account := range []string{"estilo-account", "Signed in as", "Sign out"} {
+ if strings.Contains(body, account) {
+ t.Errorf("GET %s draws the account (%q): every door is drawn signed out", target, account)
+ }
+ }
+ }
+ if !b.has(sessionCookie) {
+ t.Error("an admitted session was ended by the door")
+ }
+}
+
+// The email way is remembered: back on the door after signing out, the
+// one way in is "Continue as {address}", with "Use a different email"
+// under it; that forgets it, and the field comes back.
+func TestTheEmailWayIsRemembered(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ signIn(t, h, b, m, TestOwner, nil)
+ if !b.has(rememberName) {
+ t.Fatal("signing in remembered nothing")
+ }
+ out := b.post(t, h, "/signout", url.Values{})
+ if out.Code != http.StatusSeeOther || out.Header().Get("Location") != "/signed-out" {
+ t.Fatalf("Sign out: %d to %q, want 303 to /signed-out", out.Code, out.Header().Get("Location"))
+ }
+ if b.has(sessionCookie) {
+ t.Fatal("Sign out kept the session cookie")
+ }
+ door := b.get(t, h, "/signin").Body.String()
+ for _, want := range []string{TestOwner, "Use a different email", `action="/signin/forget"`} {
+ if !strings.Contains(door, want) {
+ t.Errorf("the returning door lacks %q:\n%s", want, door)
+ }
+ }
+ if strings.Contains(door, "Other ways to sign in") {
+ t.Error("an email-only door offers Other ways")
+ }
+ forget := b.post(t, h, "/signin/forget", url.Values{"way": {"email"}})
+ if forget.Code != http.StatusSeeOther {
+ t.Fatalf("Forget: %d", forget.Code)
+ }
+ if b.has(rememberName) {
+ t.Error("Forget kept the remembered way")
+ }
+ if door := b.get(t, h, "/signin").Body.String(); strings.Contains(door, TestOwner) || !strings.Contains(door, `name="address" required`) {
+ t.Errorf("after Forget the door is not the empty field:\n%s", door)
+ }
+}
+
+// Where Sign out lands: "You’re signed out", Sign in, and the quiet
+// "Forget me on this device", a POST to auth's Forget. Fichas has no Home,
+// so nothing chains on to Oficina ID.
+func TestSignedOutOffersForget(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ signIn(t, h, b, m, TestOwner, nil)
+ b.post(t, h, "/signout", url.Values{})
+ page := b.get(t, h, "/signed-out").Body.String()
+ for _, want := range []string{
+ "<h1>You’re signed out</h1>",
+ "You’ve signed out of Fichas on this device.",
+ `<a rst-btn="primary" estilo-signin-action href="/signin">Sign in</a>`,
+ `<form estilo-signin-forget method="post" action="/signin/forget">`,
+ ">Forget me on this device</button>",
+ } {
+ if !strings.Contains(page, want) {
+ t.Errorf("the signed-out page lacks %q:\n%s", want, page)
+ }
+ }
+ for _, gone := range []string{"chain", "oficina", "id.oficina.works"} {
+ if strings.Contains(page, gone) {
+ t.Errorf("the signed-out page chains on (%q), with no Home to chain to", gone)
+ }
+ }
+ rec := b.post(t, h, "/signin/forget", url.Values{})
+ if rec.Code != http.StatusSeeOther || !strings.HasPrefix(rec.Header().Get("Location"), "/signin") {
+ t.Errorf("Forget: %d to %q, want the door", rec.Code, rec.Header().Get("Location"))
+ }
+ if b.has(rememberName) {
+ t.Error("Forget me on this device kept the remembered way")
+ }
+ // Same-origin only, as Begin is: a cross-site form forgets nothing.
+ cross := newBrowser()
+ signIn(t, h, cross, m, TestOwner, nil)
+ if r := crossSitePost(t, h, cross, "/signin/forget"); r.Code != http.StatusForbidden {
+ t.Errorf("a cross-site Forget answered %d, want 403", r.Code)
+ }
+ if !cross.has(rememberName) {
+ t.Error("a cross-site Forget forgot")
+ }
+}
+
+// The confirm step an emailed link opens is the door, with one Sign in
+// button that POSTs the token back; its GET spends nothing and sets
+// nothing, and it is kept out of caches and referrers.
+func TestTheConfirmStepIsTheDoor(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ b := newBrowser()
+ tok := linkFor(t, h, b, m, TestOwner, nil)
+ rec := get(t, h, "/auth/verify?token="+url.QueryEscape(tok))
+ if rec.Code != http.StatusOK {
+ t.Fatalf("GET /auth/verify: %d", rec.Code)
+ }
+ if len(rec.Result().Cookies()) != 0 {
+ t.Error("the confirm step's GET set a cookie")
+ }
+ if rec.Header().Get("Cache-Control") != "no-store" || rec.Header().Get("Referrer-Policy") == "" {
+ t.Errorf("confirm headers: Cache-Control %q, Referrer-Policy %q", rec.Header().Get("Cache-Control"), rec.Header().Get("Referrer-Policy"))
+ }
+ body := rec.Body.String()
+ if got := titleOf(body); got != "Sign in to Fichas" {
+ t.Errorf("confirm title %q", got)
+ }
+ // On the one-way door, so its Sign in is the door's pill like every
+ // other state's main action.
+ for _, want := range []string{"<div estilo-signin-screen>", `<div rst-signin-door="one-way">`, `<form rst-signin-form method="post" action="/auth/verify">`, `name="token"`, ">Sign in</button>"} {
+ if !strings.Contains(body, want) {
+ t.Errorf("the confirm step lacks %q:\n%s", want, body)
+ }
+ }
+ if strings.Contains(body, TestOwner) {
+ t.Error("the confirm step names the address: the link may be open in another browser")
+ }
+}
+
+// Begin's own problems reach the door as they are, for any address: a
+// mistyped address is "That doesn't look like an email address", never a
+// cheerful Sent (no sameAnswer), with nothing mailed and no dial, and it
+// keeps force and reauth.
+func TestAMistypedAddressIsSaidSo(t *testing.T) {
+ h, m, _ := wiredApp(t)
+ for _, extra := range []url.Values{{}, {"force": {"1"}}, {"reauth": {"1"}}} {
+ form := url.Values{"address": {"not an address"}}
+ for k, v := range extra {
+ form[k] = v
+ }
+ rec := post(t, h, "/auth/begin", form)
+ loc := rec.Header().Get("Location")
+ if rec.Code != http.StatusSeeOther || !strings.HasPrefix(loc, "/signin?err=address") {
+ t.Errorf("%v: %d to %q, want the door with err=address", extra, rec.Code, loc)
+ }
+ for k := range extra {
+ if !strings.Contains(loc, k+"=1") {
+ t.Errorf("%v: %q dropped %s", extra, loc, k)
+ }
+ }
+ if body := get(t, h, loc).Body.String(); !strings.Contains(body, "That doesn&#39;t look like an email address.") {
+ t.Errorf("%q does not say so", loc)
+ }
+ }
+ if len(m.sent) != 0 {
+ t.Errorf("%d mails sent for mistyped addresses", len(m.sent))
+ }
+}
diff --git a/internal/fichastest/signin_flow_test.go b/internal/fichastest/signin_flow_test.go
index 861d51c..a7f1067 100644
--- a/internal/fichastest/signin_flow_test.go
+++ b/internal/fichastest/signin_flow_test.go
@@ -63,7 +63,7 @@ func wiredApp(t *testing.T) (http.Handler, *capturingMailer, *db.DB) {
Origin: cfg.Origin,
InstanceKey: cfg.InstanceKey,
Mailer: mailer,
- }, logger, app.Admit)
+ }, logger, app)
if err != nil {
t.Fatalf("NewAuth: %v", err)
}
@@ -107,8 +107,8 @@ func TestASignInCompletesEndToEnd(t *testing.T) {
if rec.Code != http.StatusSeeOther {
t.Fatalf("POST /auth/begin: status %d\n%s", rec.Code, rec.Body.String())
}
- if loc := rec.Header().Get("Location"); loc != "/signin?sent=1" {
- t.Fatalf("POST /auth/begin redirected to %q, want /signin?sent=1", loc)
+ if loc := rec.Header().Get("Location"); !strings.HasPrefix(loc, "/signin?sent=1&attempt=") {
+ t.Fatalf("POST /auth/begin redirected to %q, want the door's Sent", loc)
}
mail := mailer.last(t)
@@ -138,7 +138,7 @@ func TestASignInCompletesEndToEnd(t *testing.T) {
t.Fatal("GET /auth/verify set a cookie: the link's GET must spend nothing")
}
page := confirm.Body.String()
- for _, want := range []string{"estilo-door", `method="post" action="/auth/verify"`, `name="token" value="` + m[1] + `"`, ">Sign in</button>"} {
+ for _, want := range []string{"estilo-door", "<div estilo-signin-screen>", `method="post" action="/auth/verify"`, `name="token" value="` + m[1] + `"`, ">Sign in</button>"} {
if !strings.Contains(page, want) {
t.Fatalf("the confirm page is not the door with a Sign in button (missing %q):\n%s", want, page)
}
@@ -182,7 +182,7 @@ func TestASignInCompletesEndToEnd(t *testing.T) {
func TestAStrangerIsSentNothing(t *testing.T) {
h, mailer, _ := wiredApp(t)
rec := post(t, h, "/auth/begin", url.Values{"address": {"nobody@example.com"}, "force": {"1"}})
- if loc := rec.Header().Get("Location"); loc != "/signin?sent=1" {
+ if loc := rec.Header().Get("Location"); !strings.HasPrefix(loc, "/signin?sent=1&attempt=") {
t.Fatalf("a stranger was redirected to %q", loc)
}
mailer.mu.Lock()
@@ -192,15 +192,17 @@ func TestAStrangerIsSentNothing(t *testing.T) {
}
}
-// Every error code renders something a person can act on, and the email
-// fallback survives a failed keymail round trip.
+// Every error code renders something a person can act on, in
+// rastrillo's approved words, and the email fallback survives a failed
+// keymail round trip.
func TestSigninErrorsArePlainLanguage(t *testing.T) {
h, _, _ := wiredApp(t)
for code, want := range map[string]string{
- "rate": "Too many sign-in attempts",
- "expired": "has expired or has already been used",
- "keymail": "Keymail couldn",
- "1": "Something went wrong on our side",
+ "rate": "Too many tries. Try again in a few minutes.",
+ "expired": "That link has expired or was already used. Send a new one.",
+ "keymail": "Keymail couldn&#39;t confirm it&#39;s you.",
+ "address": "That doesn&#39;t look like an email address.",
+ "1": "Something went wrong. Try again.",
} {
body := get(t, h, "/signin?err="+code).Body.String()
if !strings.Contains(body, want) {
@@ -225,7 +227,7 @@ func TestTheDoorsFormStillSignsIn(t *testing.T) {
}
}
rec := post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}})
- if rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/signin?sent=1" {
+ if rec.Code != http.StatusSeeOther || !strings.HasPrefix(rec.Header().Get("Location"), "/signin?sent=1&attempt=") {
t.Fatalf("POST address=: status %d, Location %q", rec.Code, rec.Header().Get("Location"))
}
if mail := mailer.last(t); !linkToken.MatchString(mail) {
diff --git a/internal/fichastest/signin_test.go b/internal/fichastest/signin_test.go
index 9170460..4573d7f 100644
--- a/internal/fichastest/signin_test.go
+++ b/internal/fichastest/signin_test.go
@@ -7,6 +7,7 @@ import (
"net/url"
"path/filepath"
"regexp"
+ "strconv"
"strings"
"testing"
@@ -60,7 +61,8 @@ func TestProductionRefusesAnUnauthenticatedRequest(t *testing.T) {
// Sign-in itself must be reachable, or nobody can ever get in.
func TestSigninPageIsReachableWithoutASession(t *testing.T) {
- rec := get(t, productionApp(t), "/signin")
+ h, _, _ := wiredApp(t)
+ rec := get(t, h, "/signin")
if rec.Code != http.StatusOK {
t.Fatalf("GET /signin: status %d, want 200", rec.Code)
}
@@ -69,22 +71,54 @@ func TestSigninPageIsReachableWithoutASession(t *testing.T) {
}
}
+// An app with no sign-in wired draws no door: closed, as requireSession
+// is, rather than a form that posts to nothing.
+func TestNoDoorWithoutSignin(t *testing.T) {
+ if rec := get(t, productionApp(t), "/signin"); rec.Code != http.StatusInternalServerError {
+ t.Errorf("GET /signin with no auth: status %d, want 500", rec.Code)
+ }
+}
+
// beginGuard must render the SAME outcome for an owner and a stranger. A
// distinct rejection turns the guard into an owners-list oracle, which is
// worse than the dial it removes: the dial confirms the instance exists,
-// an oracle confirms who runs it.
+// an oracle confirms who runs it. With the smart door, Begin's Sent
+// carries an attempt= and sets an attempt cookie, so the guard answers a
+// stranger with rastrillo's AnswerAsSent, which does the same (Memoria
+// #49): a plain ?sent=1 would tell them apart on the first try.
func TestSigninRefusalIsIndistinguishable(t *testing.T) {
- h := productionApp(t)
-
- stranger := post(t, h, "/auth/begin", url.Values{"address": {"nobody@example.com"}})
- if stranger.Code != http.StatusSeeOther {
- t.Fatalf("a stranger's submission: status %d, want 303", stranger.Code)
+ h, mailer, _ := wiredApp(t)
+ shape := regexp.MustCompile(`^/signin\?sent=1&attempt=[A-Za-z0-9_-]{22}$`)
+ answer := func(address string) (string, []string) {
+ rec := post(t, h, "/auth/begin", url.Values{"address": {address}, "force": {"1"}})
+ if rec.Code != http.StatusSeeOther {
+ t.Fatalf("%s: status %d, want 303", address, rec.Code)
+ }
+ if strings.Contains(rec.Body.String(), address) {
+ t.Errorf("the answer to %s echoes the address back", address)
+ }
+ var names []string
+ for _, c := range rec.Result().Cookies() {
+ names = append(names, c.Name+"|"+c.Path+"|"+strconv.Itoa(c.MaxAge)+"|"+strconv.FormatBool(c.HttpOnly)+"|"+strconv.Itoa(len(c.Value)))
+ }
+ return rec.Header().Get("Location"), names
}
- if got := stranger.Header().Get("Location"); got != "/signin?sent=1" {
- t.Errorf("a stranger is redirected to %q, which names them as refused", got)
+ // Equal lengths, so the sealed attempt cookie's length says nothing.
+ owner, ownerCookies := answer(TestOwner)
+ stranger, strangerCookies := answer("zzz@example.com")
+ if len(TestOwner) != len("zzz@example.com") {
+ t.Fatal("the two addresses must be the same length")
}
- if body := stranger.Body.String(); strings.Contains(body, "nobody@example.com") {
- t.Error("the refusal page echoes the address back")
+ if !shape.MatchString(owner) || !shape.MatchString(stranger) {
+ t.Errorf("owner %q, stranger %q: want both /signin?sent=1&attempt=…", owner, stranger)
+ }
+ if strings.Join(ownerCookies, ",") != strings.Join(strangerCookies, ",") {
+ t.Errorf("cookies differ:\nowner %v\nstranger %v", ownerCookies, strangerCookies)
+ }
+ mailer.mu.Lock()
+ defer mailer.mu.Unlock()
+ if len(mailer.sent) != 1 {
+ t.Errorf("%d mails sent, want the owner's one", len(mailer.sent))
}
}
@@ -93,34 +127,39 @@ func TestSigninRefusalIsIndistinguishable(t *testing.T) {
// address in the query string was invisible to the guard and visible to
// the thing it guarded.
func TestTheGuardSeesAQueryStringAddress(t *testing.T) {
- h := productionApp(t)
- rec := post(t, h, "/auth/begin?address=nobody@example.com", url.Values{})
+ h, mailer, _ := wiredApp(t)
+ rec := post(t, h, "/auth/begin?address=nobody@example.com", url.Values{"force": {"1"}})
if rec.Code != http.StatusSeeOther {
t.Fatalf("status %d, want 303", rec.Code)
}
- if got := rec.Header().Get("Location"); got != "/signin?sent=1" {
+ if got := rec.Header().Get("Location"); !strings.HasPrefix(got, "/signin?sent=1&attempt=") {
t.Errorf("redirected to %q", got)
}
+ if len(mailer.sent) != 0 {
+ t.Error("a stranger in the query string was sent a link")
+ }
}
-// The sign-in page is the suite's door (estilo chrome): one card on the
-// Oficina sky, Fichas' own mark and name at its head, styled by the
-// chrome.css and sky.css static/ carries. The email field is named
-// address, which is what beginGuard and rastrillo both read.
+// The sign-in page is the suite's door: rastrillo's screen (one way in)
+// inside estilo's door (estilo-signin-screen), one card on the Oficina
+// sky, Fichas' own mark and name at its head, styled by the chrome.css
+// and sky.css static/ carries. The email field is named address, which
+// is what beginGuard and rastrillo both read.
func TestSigninPageIsTheDoor(t *testing.T) {
- h := productionApp(t)
+ h, _, _ := wiredApp(t)
body := get(t, h, "/signin").Body.String()
for _, want := range []string{
"estilo-door",
+ "<div estilo-signin-screen>",
+ `<div rst-signin-door="one-way">`,
"<span>Fichas</span>",
`<img estilo-sky-layer="grain"`,
`<img estilo-brand-icon="listing" src="/static/brand/icon.`,
- `<form rst-form estilo-signin-form method="post" action="/auth/begin"`,
+ `<form rst-signin-form method="post" action="/auth/begin">`,
`name="address"`,
- "<h1>Sign in</h1>",
- "Email address",
- "We’ll email you a link that signs you in. It works once and expires in 15 minutes.",
- ">Sign in</button>",
+ `<h1 id="rst-signin-heading">Sign in to Fichas</h1>`,
+ `>Email</label>`,
+ `>Continue</button>`,
`href="/static/chrome.`,
`href="/static/sky.`,
} {
@@ -128,6 +167,12 @@ func TestSigninPageIsTheDoor(t *testing.T) {
t.Errorf("the sign-in page lacks %q:\n%s", want, body)
}
}
+ // No Home: no Oficina ID, and nothing else to choose between.
+ for _, gone := range []string{"Oficina ID", "Other ways to sign in", "/signin/oficina", "Colophon", "Open source"} {
+ if strings.Contains(body, gone) {
+ t.Errorf("the door offers %q, which Fichas does not have", gone)
+ }
+ }
// The sky's layers are served, sessionless, from estilo's prefix.
src := regexp.MustCompile(`estilo-sky-layer="filaments"[^>]*src="([^"]+)"`).FindStringSubmatch(body)
@@ -138,73 +183,46 @@ func TestSigninPageIsTheDoor(t *testing.T) {
if layer.Code != http.StatusOK || layer.Header().Get("Content-Type") != "image/svg+xml" {
t.Errorf("GET %s: status %d, type %q", src[1], layer.Code, layer.Header().Get("Content-Type"))
}
-
- // The check-your-email state is the door too.
- sent := get(t, h, "/signin?sent=1").Body.String()
- for _, want := range []string{"estilo-door", "<span>Fichas</span>", "Check your email", "If that address can sign in here, we’ve sent it a link. It works once and expires in 15 minutes."} {
- if !strings.Contains(sent, want) {
- t.Errorf("the sent page lacks %q:\n%s", want, sent)
- }
- }
- if strings.Contains(sent, `name="address"`) {
- t.Error("the sent page still shows the form")
- }
}
-// The door's words are the suite's, not fichas' own: estilo owns them
-// (chrome.English), so every app's door reads the same. The submit says
-// "Sign in" (Paul, 2026-10-01) and never "Email me a link", and each
-// state's tab title is "<Page> · Fichas".
-//
-// There is no signed-out page to pin: rastrillo's Signout redirects to
-// /signin, so signing out lands on the form.
+// The door's words are rastrillo's approved copy, and each state's tab
+// title says what its heading says ("Sign in to Fichas").
func TestTheDoorSpeaksTheSuitesWords(t *testing.T) {
- h := productionApp(t)
- title := regexp.MustCompile(`<title>([^<]*)</title>`)
-
+ h, _, _ := wiredApp(t)
form := get(t, h, "/signin").Body.String()
- if got := title.FindStringSubmatch(form); got == nil || got[1] != "Sign in · Fichas" {
- t.Errorf("the sign-in page's title is %q, want %q", got, "Sign in · Fichas")
+ if got := titleOf(form); got != "Sign in to Fichas" {
+ t.Errorf("the sign-in page's title is %q, want %q", got, "Sign in to Fichas")
}
- for _, want := range []string{
- "<h1>Sign in</h1>",
- "Email address",
- "We’ll email you a link that signs you in. It works once and expires in 15 minutes.",
- ">Sign in</button>",
- } {
- if !strings.Contains(form, want) {
- t.Errorf("the sign-in page lacks %q:\n%s", want, form)
- }
- }
- for _, gone := range []string{"Email me a link", "Only people this instance already knows", "Home"} {
+ for _, gone := range []string{"Email me a link", "Only people this instance already knows", "Email address"} {
if strings.Contains(form, gone) {
t.Errorf("the sign-in page still says %q", gone)
}
}
- sent := get(t, h, "/signin?sent=1").Body.String()
- if got := title.FindStringSubmatch(sent); got == nil || got[1] != "Check your email · Fichas" {
- t.Errorf("the sent page's title is %q, want %q", got, "Check your email · Fichas")
+ b := newBrowser()
+ rec := b.post(t, h, "/auth/begin", url.Values{"address": {TestOwner}, "force": {"1"}})
+ sent := b.get(t, h, rec.Header().Get("Location")).Body.String()
+ if got := titleOf(sent); got != "Check your email to sign in to Fichas" {
+ t.Errorf("the sent page's title is %q", got)
}
for _, want := range []string{
- "<h1>Check your email</h1>",
- "If that address can sign in here, we’ve sent it a link. It works once and expires in 15 minutes.",
- `href="/signin">Use a different address</a>`,
+ `<h1 id="rst-signin-heading">Check your email</h1>`,
+ "We sent a link to <bdi>" + TestOwner + "</bdi>. The link works once and expires soon.",
+ `<form rst-signin-form method="post" action="/signin/forget">`,
+ "<span>Use a different email</span>",
} {
if !strings.Contains(sent, want) {
t.Errorf("the sent page lacks %q:\n%s", want, sent)
}
}
- if strings.Contains(sent, "a link is on its way") {
- t.Error("the sent page still carries fichas' own body")
- }
}
// The door's sky draws its first frame from inline data: images, so the
// policy the page is actually served under must allow them. Built through
// rastrillo.Handler, the same assembly Serve uses, so the CSP is real.
func TestSigninPageCSPAllowsTheSky(t *testing.T) {
- served, closeDB, err := rastrillo.Handler(rastrillo.Options{Mux: productionApp(t).(*http.ServeMux), ErrorPage: fichas.ErrorPage})
+ door, _, _ := wiredApp(t)
+ served, closeDB, err := rastrillo.Handler(rastrillo.Options{Mux: door.(*http.ServeMux), ErrorPage: fichas.ErrorPage})
if err != nil {
t.Fatalf("rastrillo.Handler: %v", err)
}
diff --git a/internal/fichastest/vendored_test.go b/internal/fichastest/vendored_test.go
index 5f46884..e4d770b 100644
--- a/internal/fichastest/vendored_test.go
+++ b/internal/fichastest/vendored_test.go
@@ -151,7 +151,9 @@ var scriptSrc = regexp.MustCompile(`<script[^>]*\ssrc="([^"]+)"`)
// — both shells — rather than the files on disk.
func TestNoOldBusyRuleIsServed(t *testing.T) {
h := newApp(t)
- for _, page := range []string{"/", "/signin"} {
+ // The door: a signed-in browser is sent on from a bare /signin, so
+ // one of its states, drawn for anybody.
+ for _, page := range []string{"/", "/signin?sent=1", "/signed-out"} {
srcs := scriptSrc.FindAllStringSubmatch(get(t, h, page).Body.String(), -1)
var busyJS int
for _, m := range srcs {