oficina / meet Public

Smart door review fixes, and Paul's ruling on the join cookie's door

Fable's review of f59ed4a (#46):
- followLink answers a Home storage failure with the same no-store 503
  as requirePerson (it was a 500); homeUnavailable is the one answer.
- home.go's comment on errHomeRemoved says what an unreadable database is.
- Tests: the guest and join-cookie tests run in team mode too; the 503
  is asserted on an invitation and on /native/meetings/start.

Paul's ruling (2026-11-22): while a join cookie is live the door opens
on the email way, with Oficina ID under Other ways. The door keeps the
federated way and forces the plain door to email (st.Way = WayEmail),
whatever the browser used last; a step-up still offers no Oficina ID. An
Oficina ID sign-in from there lands on /continue (oficinaJoinLanding,
and chooseJoinLanding for the member choice's "I'm new here"), which
follows the cookie's own invitation by its sealed hash
(continueInvitation, sharing followLink's signed-in path). No destination
or token comes from the request. Tests in Home and team modes; AGENTS.md
records the ruling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev cfa7636f6f050358223d341d0fdb37e05c305e3a parent f59ed4a
11 files changed, +307 −50
  • AGENTS.md +6 −2
  • internal/calls/app.go +2 −2
  • internal/calls/auth.go +8 −2
  • internal/calls/handlers_join.go +44 −0
  • internal/calls/home.go +11 −2
  • internal/calls/signin.go +23 −17
  • internal/calls/signin_admission.go +48 −8
  • internal/calls/signin_browser_test.go +1 −0
  • internal/calls/signin_door_calls_test.go +148 −15
  • internal/calls/signin_door_refusal_test.go +13 −0
  • test/browser/call.mjs +3 −2

CI passed — run details

CI log
=== vet ===
go vet ./...
go vet -tags browser ./internal/calls/ ./internal/callstest/
=== fmt ===
=== test ===
go test ./...
ok  	amadan.net/oficina/calls/callscore	(cached)
ok  	amadan.net/oficina/calls/cmd/calls	13.403s
?   	amadan.net/oficina/calls/cmd/calls-contract	[no test files]
ok  	amadan.net/oficina/calls/cmd/quality-summary	(cached)
?   	amadan.net/oficina/calls/gen	[no test files]
ok  	amadan.net/oficina/calls/gen/locales	(cached)
ok  	amadan.net/oficina/calls/internal/calls	14.525s
ok  	amadan.net/oficina/calls/internal/calls/apns	(cached)
ok  	amadan.net/oficina/calls/internal/calls/hub	(cached)
?   	amadan.net/oficina/calls/internal/calls/icons	[no test files]
?   	amadan.net/oficina/calls/internal/calls/keymailtest	[no test files]
ok  	amadan.net/oficina/calls/internal/calls/relay	(cached)
ok  	amadan.net/oficina/calls/internal/calls/seal	(cached)
?   	amadan.net/oficina/calls/internal/calls/teamstate	[no test files]
ok  	amadan.net/oficina/calls/internal/callstest	12.598s
ok  	amadan.net/oficina/calls/protocol	(cached)
?   	amadan.net/oficina/calls/scripts/writeestilo	[no test files]
=== migration-check ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo migration check
rastrillo migration check: models and migrations agree
=== race ===
CGO_ENABLED=1 go test -race ./internal/...
ok  	amadan.net/oficina/calls/internal/calls	108.191s
ok  	amadan.net/oficina/calls/internal/calls/apns	(cached)
ok  	amadan.net/oficina/calls/internal/calls/hub	(cached)
?   	amadan.net/oficina/calls/internal/calls/icons	[no test files]
?   	amadan.net/oficina/calls/internal/calls/keymailtest	[no test files]
ok  	amadan.net/oficina/calls/internal/calls/relay	(cached)
ok  	amadan.net/oficina/calls/internal/calls/seal	(cached)
?   	amadan.net/oficina/calls/internal/calls/teamstate	[no test files]
ok  	amadan.net/oficina/calls/internal/callstest	49.257s
diff --git a/AGENTS.md b/AGENTS.md
index b0119c0..c88f09e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -41,8 +41,12 @@ mechanically.
`signin_admission.go`'s probe of `requirePerson` (a 5xx is undecided,
never a refusal). Guests are not the door's business: joining by name at
`/j/{token}` is untouched, a guest session is never judged, refused or
- ended at the door, and the join cookie's door is the email way only,
- never Oficina ID. A native app's session is its own row and never
+ ended at the door. While a join cookie is live the door opens on the
+ email way, with Oficina ID under Other ways (Paul's ruling, 2026-11-22,
+ oficina/meet #46), and an Oficina ID sign-in from there lands on
+ `/continue`, which follows the cookie's own invitation
+ (`continueInvitation`), as an emailed link does. A native app's
+ session is its own row and never
reaches the door. Oficina ID is remembered in `MintHomeSession`, for an
admitted session only. `POST /signin` is Begin behind `gateBegin` and
`beginSignin`, which keeps `return_to` in Calls' own return memory
diff --git a/internal/calls/app.go b/internal/calls/app.go
index ed5d2e0..3f7a942 100644
--- a/internal/calls/app.go
+++ b/internal/calls/app.go
@@ -581,7 +581,7 @@ func build(ctx context.Context, d *db.DB, cfg Config) (*http.ServeMux, *app, err
r.Post("/auth/verify", a.home.routes.LocalGuard(authPlugin.Verify))
r.Post("/signout", a.homeSignout)
r.Get(connect.SigninLocalPath, a.home.routes.LocalGuard(a.homeDoor(a.home.routes.SigninLocal)))
- r.Get(connect.SigninOficinaPath, a.homeDoor(a.home.routes.SigninOficina))
+ r.Get(connect.SigninOficinaPath, a.homeDoor(a.oficinaJoinLanding(a.home.routes.SigninOficina)))
r.Get("/signed-out", a.home.routes.SignedOut)
r.Get("/auth/start", a.home.bridge.Start)
r.Post("/auth/assertion", a.home.bridge.Callback)
@@ -591,7 +591,7 @@ func build(ctx context.Context, d *db.DB, cfg Config) (*http.ServeMux, *app, err
// the team hooks): no session yet, and the POST inside the
// CSRF check like any form (connect also demands this Origin).
r.Get(connect.ChoosePath, a.home.bridge.ChoosePage)
- r.Post(connect.ChoosePath, a.home.bridge.ChoosePost)
+ r.Post(connect.ChoosePath, a.chooseJoinLanding(a.home.bridge.ChoosePost))
}
r.Get("/j/{token}", a.followLink)
r.Post("/j/{token}/guest", a.joinGuest)
diff --git a/internal/calls/auth.go b/internal/calls/auth.go
index 16f2ebf..d79e501 100644
--- a/internal/calls/auth.go
+++ b/internal/calls/auth.go
@@ -248,8 +248,7 @@ func (a *app) requirePerson(next http.Handler) http.Handler {
// which the sign-in door's admission probe would read as a
// refusal and answer by ending the session
// (signin_admission.go). Team mode already answers so.
- w.Header().Set("Cache-Control", "no-store")
- a.ErrorPage(w, r, http.StatusServiceUnavailable, "")
+ a.homeUnavailable(w, r)
return
}
if errors.Is(err, errHomeIdentity) {
@@ -318,6 +317,13 @@ func (a *app) continueSignedIn(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, dest, http.StatusSeeOther)
return
}
+ // The invitation a join cookie names, when no pending join answered
+ // for it: an Oficina ID sign-in from the join cookie's door lands here
+ // (signin_admission.go's oficinaJoinLanding).
+ if a.continueInvitation(w, r) {
+ a.forgetReturn(w)
+ return
+ }
// Where the person was going when they were asked to sign in
// (signin_return.go), spent either way.
ret, remembered := a.rememberedReturn(r)
diff --git a/internal/calls/handlers_join.go b/internal/calls/handlers_join.go
index 9b3ca00..a30549a 100644
--- a/internal/calls/handlers_join.go
+++ b/internal/calls/handlers_join.go
@@ -2,6 +2,7 @@ package calls
import (
"amadan.net/oficina/home/teammode"
+ rauth "amadan.net/rastrillo/rastrillo/auth"
"amadan.net/rastrillo/rastrillo/sessions"
"errors"
"html/template"
@@ -43,11 +44,25 @@ func (a *app) followLink(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, signinPath, http.StatusSeeOther)
return
}
+ a.enterThroughLink(w, r, id, link, m, host)
+}
+
+// enterThroughLink is followLink for a signed-in session: the meeting's
+// holding screen, with a grant through the link for a non-member. It is
+// also /continue's way into the invitation a join cookie names
+// (continueInvitation), for a sign-in that left no pending join (an
+// Oficina ID sign-in chosen under Other ways).
+func (a *app) enterThroughLink(w http.ResponseWriter, r *http.Request, id rauth.Identity, link MeetingLink, m Meeting, host *teammode.Access) {
if a.team != nil {
a.teamFollowSignedIn(w, r, sessions.Session{Subject: id.Address, Method: string(id.Method), AuthTime: id.AuthTime, At: id.At}, link, m, host)
return
}
p, err := a.personForSession(r.Context(), sessions.Session{Subject: id.Address, Method: string(id.Method), AuthTime: id.AuthTime, At: id.At})
+ if errors.Is(err, errHomeUnavailable) {
+ // Storage, not identity: retryable, as requirePerson answers it.
+ a.homeUnavailable(w, r)
+ return
+ }
if errors.Is(err, errHomeIdentity) {
a.ErrorPage(w, r, http.StatusNotFound, "")
return
@@ -82,6 +97,35 @@ func (a *app) followLink(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/m/"+m.Sqid+"/join", http.StatusSeeOther)
}
+// continueInvitation is /continue's last branch before the landing: a
+// live join cookie that no pending join answered (continuePending) is the
+// invitation this sign-in was for, and the signed-in person enters through
+// it as followLink would have let them. Only the cookie's own link, by its
+// sealed hash, is ever followed, so the token is never copied into a URL.
+// It reports whether it answered.
+func (a *app) continueInvitation(w http.ResponseWriter, r *http.Request) bool {
+ ck, ok := a.readJoinCookie(r)
+ if !ok {
+ return false
+ }
+ link, m, live, err := a.store.liveLinkByHash(r.Context(), ck.TokenHash)
+ if err != nil || !live {
+ return false
+ }
+ id, signedIn := a.auth.SessionFrom(r)
+ if !signedIn {
+ return false
+ }
+ var host *teammode.Access
+ if a.team != nil {
+ if host, ok = a.teamLinkHost(w, r, m); !ok {
+ return true
+ }
+ }
+ a.enterThroughLink(w, r, id, link, m, host)
+ return true
+}
+
// holding is GET /m/{sqid}/join, authorized by standing or a live
// participation for this session (spec §2.5), the same row the room
// page uses.
diff --git a/internal/calls/home.go b/internal/calls/home.go
index aadc4f6..7a4dd19 100644
--- a/internal/calls/home.go
+++ b/internal/calls/home.go
@@ -20,8 +20,9 @@ var errHomeIdentity = errors.New("calls: Home identity refused")
// errHomeRemoved is the definite subset of errHomeIdentity: the Home
// link is refused, the person row is gone, or the person is no longer a
-// member. A database that could not be read is errHomeIdentity alone,
-// and never ends a session.
+// member. A database that could not be read is never either: it is
+// errHomeUnavailable outside team mode and errTeamUnavailable in it, a
+// retryable 503 that never ends a session.
var errHomeRemoved = fmt.Errorf("%w: removed", errHomeIdentity)
// errHomeUnavailable is a Home session's identity storage that could not
@@ -31,6 +32,14 @@ var errHomeRemoved = fmt.Errorf("%w: removed", errHomeIdentity)
// door's admission probe would read as a refusal.
var errHomeUnavailable = errors.New("calls: Home identity storage unavailable")
+// homeUnavailable is the answer to errHomeUnavailable, wherever a
+// handler meets it: a no-store 503, the page for a page request and plain
+// text for anything else (ErrorPage decides).
+func (a *app) homeUnavailable(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "no-store")
+ a.ErrorPage(w, r, http.StatusServiceUnavailable, "")
+}
+
type homeIntegration struct {
bridge *connect.Bridge
routes *connect.Routes
diff --git a/internal/calls/signin.go b/internal/calls/signin.go
index b8183ba..7b97aa0 100644
--- a/internal/calls/signin.go
+++ b/internal/calls/signin.go
@@ -70,10 +70,10 @@ func doorIcon() string { return assets.Path("static/brand/icon.svg") }
// cookies (SigninState: the way in it used last, Sent, problems, the
// chooser), with SigninOneWay drawing one way in per page. Calls adds what
// only it knows: Oficina ID where connect says the door may offer it
-// (OficinaHref is "" on /signin/local, on a step-up and standalone) and
-// no invitation is waiting on an emailed link (joining), the refusal,
-// which only someone who has just verified the address, or whose session
-// the signed-in routes no longer admit, reaches, and the removal.
+// (OficinaHref is "" on /signin/local, on a step-up and standalone), the
+// email way first while an invitation waits (joining), the refusal, which
+// only someone who has just verified the address, or whose session the
+// signed-in routes no longer admit, reaches, and the removal.
func (a *app) signinDoor(w http.ResponseWriter, r *http.Request) {
a.signinDoorStatus(w, r, http.StatusOK)
}
@@ -87,7 +87,7 @@ func (a *app) signinDoorStatus(w http.ResponseWriter, r *http.Request, status in
a.notFound(w, r)
return
}
- if href := connect.OficinaHref(r); href != "" && !joining(r) {
+ if href := connect.OficinaHref(r); href != "" {
st.Federated = &rauth.FederatedDoor{
Provider: lastsignin.ProviderOficina,
Href: href,
@@ -95,6 +95,13 @@ func (a *app) signinDoorStatus(w http.ResponseWriter, r *http.Request, status in
Icon: chrome.OficinaGlyph,
}
}
+ if joining(r) && st.Way == "" {
+ // Paul's ruling (2026-11-22, #46): on the way into a call, email
+ // is the door's default, whatever this browser used last, with
+ // Oficina ID a row under Other ways. An outsider gets in by the
+ // pending join an emailed link proves (spec §3.2).
+ st.Way = rauth.WayEmail
+ }
switch {
case refusedHere(r):
st.AppProblem = &rauth.AppProblem{Text: signinRefusal, Ask: true}
@@ -160,11 +167,11 @@ func (a *app) refused(w http.ResponseWriter, r *http.Request, _ rauth.Identity)
}
// refusedKey and removedKey mark a request the door draws with the refusal
-// or the removal; noOficinaKey one that must not offer Oficina ID.
+// or the removal; joiningKey one drawn while an invitation waits.
type (
- refusedKey struct{}
- removedKey struct{}
- noOficinaKey struct{}
+ refusedKey struct{}
+ removedKey struct{}
+ joiningKey struct{}
)
// withRefusal marks r as a refusal the door draws: a verified address
@@ -217,18 +224,17 @@ func removedHere(r *http.Request) bool {
}
// joining reports whether the door is being drawn for somebody on their
-// way into a call through an invitation that needs an emailed sign-in
-// (the join cookie, joincookie.go): the door is the email way only, as it
-// always was there (signinRoute). An outsider's way in is a pending join
-// the emailed link proves (spec §3.2), which Oficina ID cannot.
+// way into a call through an invitation (the join cookie, joincookie.go):
+// email is the door's default way, and Oficina ID one of its other ways
+// (signinRoute; Paul's ruling, 2026-11-22).
func joining(r *http.Request) bool {
- v, _ := r.Context().Value(noOficinaKey{}).(bool)
+ v, _ := r.Context().Value(joiningKey{}).(bool)
return v
}
-// withoutOficina marks r as joining.
-func withoutOficina(r *http.Request) *http.Request {
- return r.WithContext(context.WithValue(r.Context(), noOficinaKey{}, true))
+// withJoining marks r as joining.
+func withJoining(r *http.Request) *http.Request {
+ return r.WithContext(context.WithValue(r.Context(), joiningKey{}, true))
}
// renderSignedOut is where Sign out lands: /signed-out, in both modes, in
diff --git a/internal/calls/signin_admission.go b/internal/calls/signin_admission.go
index 19faebc..3e8d3de 100644
--- a/internal/calls/signin_admission.go
+++ b/internal/calls/signin_admission.go
@@ -35,24 +35,44 @@ import (
// signinRoute is GET /signin: the door. With Home, connect's SigninDoor
// behind the admission check; standalone, standaloneSignin.
//
-// The join cookie (joincookie.go: an invitation whose meeting needs an
-// emailed sign-in, which this browser followed) keeps what it always had:
-// the door with email as the one way in, never Oficina ID. An outsider is
-// let in by the pending join the emailed link proves (spec §3.2), and
-// Oficina ID would only send them round Home and back to a refusal. Before
-// the smart door this was a call straight to the local form; it is now the
-// same door, drawn without the federated way (joining).
+// The join cookie (joincookie.go: an invitation this browser followed)
+// opens the door on the email way, whatever the browser used last, with
+// Oficina ID under Other ways (Paul's ruling, 2026-11-22, #46). An
+// outsider is let in by the pending join the emailed link proves (spec
+// §3.2); a member may use either, and an Oficina ID sign-in lands back on
+// the invitation (oficinaJoinLanding). Before the smart door this was a
+// call straight to the local form, email only.
func (a *app) signinRoute(w http.ResponseWriter, r *http.Request) {
if a.home == nil {
a.standaloneSignin(w, r)
return
}
if _, pending := a.readJoinCookie(r); pending {
- r = withoutOficina(r)
+ r = withJoining(r)
}
a.homeDoor(a.home.routes.SigninDoor)(w, r)
}
+// oficinaJoinLanding is GET /signin/oficina while a join cookie is live:
+// the Home exchange lands on /continue, as an emailed link does, instead
+// of the page return_to named, so the sign-in goes on into the invitation
+// the cookie names (continueInvitation). /continue is a fixed local path,
+// and the invitation is read from the sealed cookie by its hash, so no
+// destination or token is taken from the request. A step-up is left to
+// SigninOficina, which sends it to the email-only door.
+func (a *app) oficinaJoinLanding(next http.HandlerFunc) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ q := r.URL.Query()
+ if _, pending := a.readJoinCookie(r); pending && !q.Has("reauth") {
+ q.Set("return_to", "/continue")
+ r = r.Clone(r.Context())
+ r.URL.RawQuery = q.Encode()
+ r.RequestURI = r.URL.RequestURI()
+ }
+ next(w, r)
+ }
+}
+
// homeDoor is one of connect's three door routes as Calls mounts it: under
// Home's session middleware, which clears a cookie whose session is
// definitively gone (and leaves it on a storage failure), so a stale cookie
@@ -277,3 +297,23 @@ func alreadySignedIn(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-store")
http.Redirect(w, r, target, http.StatusSeeOther)
}
+
+// chooseJoinLanding is the member choice's POST while a join cookie is
+// live: connect lands "I'm new here" on "/", whatever the exchange was
+// started for, so that one redirect goes to /continue instead, which
+// follows the invitation (continueInvitation), as oficinaJoinLanding does
+// for every other Oficina ID sign-in. Any other answer is passed on.
+func (a *app) chooseJoinLanding(next http.HandlerFunc) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ if _, pending := a.readJoinCookie(r); !pending {
+ next(w, r)
+ return
+ }
+ result := &bufferedResponse{header: make(http.Header)}
+ next(result, r)
+ if result.status == http.StatusSeeOther && result.header.Get("Location") == "/" {
+ result.header.Set("Location", "/continue")
+ }
+ result.replay(w)
+ }
+}
diff --git a/internal/calls/signin_browser_test.go b/internal/calls/signin_browser_test.go
index f891546..c4e1b64 100644
--- a/internal/calls/signin_browser_test.go
+++ b/internal/calls/signin_browser_test.go
@@ -82,6 +82,7 @@ func TestSmartDoorInABrowser(t *testing.T) {
{Name: "the removal", Path: "/signin?err=removed", want: "Your access has been removed"},
{Name: "the refusal", Path: "/__refusal", want: "That email can’t sign in to Calls."},
{Name: "the join cookie", Path: "/signin", jar: joinJar, want: "Email"},
+ {Name: "the join cookie's other ways", Path: "/signin?ways=1&way=email", jar: joinJar, want: "Oficina ID"},
{Name: "confirm", Path: confirm, want: "Sign in"},
{Name: "signed out", Path: "/signed-out", want: "Forget me on this device"},
}
diff --git a/internal/calls/signin_door_calls_test.go b/internal/calls/signin_door_calls_test.go
index 8abba9e..179fc2f 100644
--- a/internal/calls/signin_door_calls_test.go
+++ b/internal/calls/signin_door_calls_test.go
@@ -8,10 +8,13 @@ import (
"context"
"net/http"
"net/url"
+ "regexp"
"strings"
"testing"
"time"
+ "amadan.net/oficina/home/connect"
+ "amadan.net/rastrillo/rastrillo/lastsignin"
"amadan.net/rastrillo/rastrillo/sessions"
)
@@ -31,14 +34,37 @@ func doorMeeting(t *testing.T, f *homeRouterFixture, requireSignin bool) (string
return m.Sqid, token
}
+// doorMeetingModes runs fn with Home, without, and in team mode, each with
+// a way to make a meeting (by a member, then from an empty jar) and
+// return its sqid and invitation token.
+func doorMeetingModes(t *testing.T, fn func(t *testing.T, f *homeRouterFixture, meeting func(requireSignin bool) (string, string))) {
+ doorModes(t, func(t *testing.T, f *homeRouterFixture) {
+ fn(t, f, func(requireSignin bool) (string, string) { return doorMeeting(t, f, requireSignin) })
+ })
+ t.Run("team", func(t *testing.T) {
+ tf := newTeamFixture(t)
+ fn(t, tf.homeRouterFixture, func(requireSignin bool) (string, string) {
+ tf.member(teamSubject('h'), "member")
+ sqid, token := tf.meeting("Planning")
+ if requireSignin {
+ if _, err := tf.app.db.Writer().Exec("UPDATE meetings SET require_signin = 1 WHERE sqid = ?", sqid); err != nil {
+ t.Fatal(err)
+ }
+ }
+ tf.cookies = map[string]*http.Cookie{}
+ return sqid, token
+ })
+ })
+}
+
// Paul's ruling: Calls guests join by name by default, Oficina ID only on
// explicit choice. The guest's way in is the invitation, untouched by the
// door: the name form, the guest session, the holding screen. And a guest
// who then opens the door is drawn it as anybody signed out is: never sent
// to a page that 404s for a guest, never refused, never signed out.
func TestAGuestJoiningByNameIsUnaffected(t *testing.T) {
- doorModes(t, func(t *testing.T, f *homeRouterFixture) {
- sqid, token := doorMeeting(t, f, false)
+ doorMeetingModes(t, func(t *testing.T, f *homeRouterFixture, meeting func(bool) (string, string)) {
+ sqid, token := meeting(false)
invite := f.get("/j/" + token)
if invite.Code != http.StatusOK || !strings.Contains(invite.Body.String(), `name="name"`) {
t.Fatalf("the invitation = %d, want the name form", invite.Code)
@@ -70,17 +96,17 @@ func TestAGuestJoiningByNameIsUnaffected(t *testing.T) {
})
}
-// The join cookie (an invitation to a meeting that needs an emailed
-// sign-in) keeps the door the email way only, never Oficina ID, with Home
-// as without; and an outsider signing in through it lands in the meeting,
-// the pending join taken at /continue.
-func TestTheJoinCookieSigninIsEmailOnly(t *testing.T) {
- doorModes(t, func(t *testing.T, f *homeRouterFixture) {
- sqid, token := doorMeeting(t, f, true)
+// An outsider through the join cookie (an invitation to a meeting that
+// needs an emailed sign-in) signs in by email, as ever, and lands in the
+// meeting, the pending join taken at /continue. The door opens on the
+// email field: Oficina ID is not its default there.
+func TestAnEmailSigninThroughTheJoinCookie(t *testing.T) {
+ doorMeetingModes(t, func(t *testing.T, f *homeRouterFixture, meeting func(bool) (string, string)) {
+ sqid, token := meeting(true)
redirectsTo(t, f.get("/j/"+token), "/signin")
rec := f.get("/signin")
card := door(t, rec.Body.String())
- if rec.Code != http.StatusOK || strings.Contains(card, "Oficina ID") || strings.Contains(card, "/signin/oficina") || !strings.Contains(card, emailField) {
+ if rec.Code != http.StatusOK || strings.Contains(card, oficinaButton) || !strings.Contains(card, emailField) {
t.Fatalf("the door with a join cookie: %d\n%s", rec.Code, card)
}
if got := f.emailSignin(t, url.Values{"address": {"outsider@example.test"}}); got != "/m/"+sqid+"/join" {
@@ -92,19 +118,126 @@ func TestTheJoinCookieSigninIsEmailOnly(t *testing.T) {
})
}
-// Without the join cookie, the same browser's door offers Oficina ID again
-// (with Home): the cookie, not the browser, decides.
-func TestTheJoinCookieAloneTakesOficinaIDAway(t *testing.T) {
+// Paul's ruling (2026-11-22, #46): while an invitation waits, the plain
+// door is the email way, whatever the browser used last, and Oficina ID is
+// a row under Other ways. A step-up still never offers it. With Home, in
+// both modes.
+func TestTheJoinCookieDoorIsEmailFirstWithOficinaIDUnderOtherWays(t *testing.T) {
+ homeMeetingModes(t, func(t *testing.T, f *homeRouterFixture, meeting func(bool) (string, string)) {
+ _, token := meeting(true)
+ f.get("/j/" + token)
+ card := door(t, f.get("/signin").Body.String())
+ if strings.Contains(card, oficinaButton) || !strings.Contains(card, emailField) || !strings.Contains(card, otherWays) {
+ t.Fatalf("the join cookie's plain door:\n%s", card)
+ }
+ chooser := door(t, f.get(waysHref(t, card)).Body.String())
+ if !strings.Contains(chooser, "Oficina ID") || !strings.Contains(chooser, `href="/signin?way=oficina"`) {
+ t.Fatalf("the join cookie's chooser has no Oficina ID row:\n%s", chooser)
+ }
+ if way := door(t, f.get("/signin?way=oficina").Body.String()); !strings.Contains(way, oficinaButton) {
+ t.Fatalf("the Oficina ID row's page:\n%s", way)
+ }
+ for _, step := range []string{"/signin?reauth=1", "/signin?reauth=1&ways=1&way=email"} {
+ if card := door(t, f.get(step).Body.String()); strings.Contains(card, "Oficina ID") {
+ t.Fatalf("a step-up with a join cookie offers Oficina ID (%s):\n%s", step, card)
+ }
+ }
+ // Remembered Oficina ID does not make it the default either: the
+ // email way, with the remembered address.
+ f.remember(t, lastsignin.Record{Method: lastsignin.MethodFederated, Provider: lastsignin.ProviderOficina, Address: "alice@example.test"})
+ card = door(t, f.get("/signin").Body.String())
+ if strings.Contains(card, oficinaButton) || !strings.Contains(card, "Continue as alice@example.test") {
+ t.Fatalf("the join cookie's door with Oficina ID remembered:\n%s", card)
+ }
+ })
+}
+
+// Without the join cookie, the same browser's door opens on Oficina ID
+// again (with Home): the cookie, not the browser, decides.
+func TestTheJoinCookieAloneMakesEmailTheDefault(t *testing.T) {
f := newHomeRouterFixture(t)
_, token := doorMeeting(t, f, true)
f.get("/j/" + token)
if card := door(t, f.get("/signin").Body.String()); strings.Contains(card, oficinaButton) {
- t.Fatal("the join cookie's door offers Oficina ID")
+ t.Fatal("the join cookie's door opens on Oficina ID")
}
delete(f.cookies, joinCookieName)
if card := door(t, f.get("/signin").Body.String()); !strings.Contains(card, oficinaButton) {
- t.Fatalf("without the join cookie the door offers no Oficina ID:\n%s", card)
+ t.Fatalf("without the join cookie the door does not open on Oficina ID:\n%s", card)
+ }
+}
+
+// An Oficina ID sign-in chosen under Other ways, with an invitation
+// waiting, lands on the invitation, as an email sign-in does through
+// /continue: the exchange lands on /continue, never on a page the request
+// named, and /continue follows the cookie's own link.
+func TestAnOficinaSigninFromTheJoinCookieLandsOnTheInvitation(t *testing.T) {
+ t.Run("home", func(t *testing.T) {
+ f := newHomeRouterFixture(t)
+ f.link(t)
+ homeSignout(t, f.do(http.MethodPost, "/signout", ""))
+ sqid, token := doorMeeting(t, f, true)
+ redirectsTo(t, f.get("/j/"+token), "/signin")
+ start := homeRedirect(t, f.get("/signin/oficina?return_to=%2Fsettings"))
+ if !strings.Contains(start, "return_to=%2Fcontinue") {
+ t.Fatalf("the exchange starts for %q, want /continue", start)
+ }
+ landing := homeRedirect(t, f.exchange(t, start, "opaque-home-alice"))
+ if landing != "/continue" {
+ t.Fatalf("the exchange landed on %q", landing)
+ }
+ redirectsTo(t, f.get(landing), "/m/"+sqid+"/join")
+ if f.cookies[joinCookieName] != nil {
+ t.Fatal("the join cookie outlived the sign-in")
+ }
+ })
+ t.Run("team", func(t *testing.T) {
+ tf := newTeamFixture(t)
+ tf.member(teamSubject('h'), "member")
+ sqid, token := tf.meeting("Planning")
+ if _, err := tf.app.db.Writer().Exec("UPDATE meetings SET require_signin = 1 WHERE sqid = ?", sqid); err != nil {
+ t.Fatal(err)
+ }
+ joiner := teamSubject('j')
+ tf.dir.Set(joiner, "member")
+ tf.refreshed()
+ tf.cookies = map[string]*http.Cookie{}
+ redirectsTo(t, tf.get("/j/"+token), "/signin")
+ start := homeRedirect(t, tf.get("/signin/oficina"))
+ fin := tf.exchange(t, start, joiner)
+ if fin.Code == http.StatusSeeOther && fin.Header().Get("Location") == connect.ChoosePath {
+ fin = tf.choose("new")
+ }
+ landing := homeRedirect(t, fin)
+ if landing != "/continue" {
+ t.Fatalf("the exchange landed on %q", landing)
+ }
+ redirectsTo(t, tf.get(landing), "/m/"+sqid+"/join")
+ if w := tf.get("/m/" + sqid + "/join"); w.Code != http.StatusOK {
+ t.Fatalf("the member's holding screen = %d", w.Code)
+ }
+ })
+}
+
+// homeMeetingModes is doorMeetingModes with Home only: with Home and in
+// team mode.
+func homeMeetingModes(t *testing.T, fn func(t *testing.T, f *homeRouterFixture, meeting func(bool) (string, string))) {
+ doorMeetingModes(t, func(t *testing.T, f *homeRouterFixture, meeting func(bool) (string, string)) {
+ if f.app.home == nil {
+ t.Skip("no Oficina ID without Home")
+ }
+ fn(t, f, meeting)
+ })
+}
+
+// waysHref is the door's "Other ways to sign in" href, unescaped.
+func waysHref(t *testing.T, card string) string {
+ t.Helper()
+ m := regexp.MustCompile(`href="(/signin\?[^"]*ways=1[^"]*)"`).FindStringSubmatch(card)
+ if m == nil {
+ t.Fatalf("no Other ways link:\n%s", card)
}
+ return m[1]
}
// A native app's session (native_auth.go: a session of its own, a copy of
diff --git a/internal/calls/signin_door_refusal_test.go b/internal/calls/signin_door_refusal_test.go
index a74b011..2534aa4 100644
--- a/internal/calls/signin_door_refusal_test.go
+++ b/internal/calls/signin_door_refusal_test.go
@@ -160,6 +160,7 @@ func TestAnUndecidedGateIsNoRefusal(t *testing.T) {
f := newHomeRouterFixture(t)
f.link(t)
session := f.sessionCookie().Value
+ _, token := doorMeeting(t, f, false)
if _, err := f.app.db.Writer().Exec("ALTER TABLE persons RENAME TO persons_away"); err != nil {
t.Fatal(err)
}
@@ -167,6 +168,18 @@ func TestAnUndecidedGateIsNoRefusal(t *testing.T) {
if rec := f.doWith(http.MethodGet, "/", "", http.Header{"Accept": {"text/html"}}); rec.Code != http.StatusServiceUnavailable || rec.Header().Get("Cache-Control") != "no-store" {
t.Fatalf("a page with identity storage down = %d %q, want a no-store 503", rec.Code, rec.Header().Get("Cache-Control"))
}
+ // The same no-store 503 everywhere storage is met: an invitation
+ // followed signed in, and the native apps' API (a deliberate change:
+ // outside team mode this was a 404, or a 500 on the invitation).
+ if rec := f.doWith(http.MethodGet, "/j/"+token, "", http.Header{"Accept": {"text/html"}}); rec.Code != http.StatusServiceUnavailable || rec.Header().Get("Cache-Control") != "no-store" {
+ t.Fatalf("following an invitation with identity storage down = %d %q, want a no-store 503", rec.Code, rec.Header().Get("Cache-Control"))
+ }
+ if rec := f.doWith(http.MethodPost, "/native/meetings/start", `{}`, http.Header{"Content-Type": {"application/json"}}); rec.Code != http.StatusServiceUnavailable || rec.Header().Get("Cache-Control") != "no-store" {
+ t.Fatalf("the native API with identity storage down = %d %q, want a no-store 503", rec.Code, rec.Header().Get("Cache-Control"))
+ }
+ if !f.liveSession(session) {
+ t.Fatal("a 503 ended the session")
+ }
rec := f.get("/signin")
if strings.Contains(rec.Body.String(), signinRefusal) || strings.Contains(rec.Body.String(), signinRemoved) {
t.Fatal("the door refused a session it could not judge")
diff --git a/test/browser/call.mjs b/test/browser/call.mjs
index 851278b..f5bd666 100644
--- a/test/browser/call.mjs
+++ b/test/browser/call.mjs
@@ -1170,9 +1170,10 @@ async function signInAsGuest(ctx, address = GUEST) {
'the link sends a signed-out outsider to sign in (at ' + where(page) + ')');
// The smart door's email way (rastrillo's screen in estilo's door):
- // the join cookie's door is the email field alone, never Oficina ID.
+ // while the join cookie is live the door opens on the email field, with
+ // Oficina ID only under Other ways (Paul's ruling, 2026-11-22).
check(await page.locator('a[href^="/signin/oficina"]').count() === 0,
- 'the join cookie\'s door offers no Oficina ID (at ' + where(page) + ')');
+ 'the join cookie\'s door opens on email, not Oficina ID (at ' + where(page) + ')');
await page.fill('input[name="address"]', address);
// Sent is /signin?sent=1&attempt=<id>: the attempt names the address on
// the page and differs every time, the same shape for anybody.