oficina / home Public

connect: optional Unlinked and HomeOnly hooks for Home-only people

Set together or not at all (New refuses one alone); with both nil every
existing consumer behaves exactly as before. HomeOnly reads the addressless
person a subject was given and is consulted after the account link in
Resolve, ResolveSession and completion, so connect's same-person rules hold
for Home-only people. Unlinked may create that person, and is asked only in
ordinary completion, after the assertion is consumed, for a subject with no
link and no Home-only person, and only when no app session is present.
ErrNoPerson is answered as an unlinked subject always was ("unknown", 403,
resume marker); anything else is a 503. A Home-only person must have a
positive ID and no label. Replaces Sheets' private team_home.go completion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 6b23c73a22c693e63c40282397e2e826114694d7 parent 15833f7
5 files changed, +379 −5
  • connect/README.md +31 −0
  • connect/api.go +52 −1
  • connect/bridge.go +19 −4
  • connect/bridge_test.go +10 −0
  • connect/unlinked_test.go +267 −0

CI passed — run details

diff --git a/connect/README.md b/connect/README.md
index c258ad4..5ef7703 100644
--- a/connect/README.md
+++ b/connect/README.md
@@ -87,6 +87,37 @@ then ends the POST with a no-store continuation page so Safari does not apply
form-action to Keymail's redirect chain. It does not discover or trust arbitrary
request-provided destinations. Keep the existing local plugin callback route.
+## Home-only people (team mode)
+
+`Config.Unlinked` and `Config.HomeOnly` are optional and set together; `New`
+refuses one without the other. Without them nothing above changes. With them, a
+subject with no account link here can still sign in, as an addressless
+person the app creates, which is what team mode needs for a roster member
+who has never had a local account (`home/teammode`,
+`implementation/teammode-package.md`).
+
+- `HomeOnly(ctx, issuer, subject)` reads, never creates, the person a subject
+ was given. Connect asks it after the account link wherever it resolves a
+ Home subject: `Resolve`, `ResolveSession` and completion, so the
+ same-person rules hold for Home-only people too. It returns `ErrNoPerson`
+ for none. The person has a positive ID and an empty `Label`; connect
+ refuses one with a label, because there is no address to give.
+- `Unlinked(ctx, issuer, subject)` may create that person. Connect asks it
+ only in ordinary completion (never the link flow), only after the
+ assertion is verified and consumed, only when the subject has neither a
+ link nor a Home-only person, and only when no app session is present. In
+ team mode it creates a person only on a current roster Member decision
+ whose lease is valid (`teammode.Runtime.AdmitUnlinked`). `ErrNoPerson` is
+ answered exactly as an unlinked subject without the hook ("unknown", 403,
+ with the resume-linking marker); any other error is a 503.
+- A subject arriving over a live session is never allocated: an unknown one
+ is refused as "unknown", and a known one that is not the signed-in person
+ is refused as "failed", leaving that session in place. Every cookie shape
+ check stays connect's.
+
+`Bridge.Linked` knows nothing of Home-only people, so an app should not offer
+"Connect your Oficina account" to one: there is no local account to connect.
+
## Extraction record
The link proof protocol, bridge, freshness rules and navigation originate in
diff --git a/connect/api.go b/connect/api.go
index 17f7f94..abefd56 100644
--- a/connect/api.go
+++ b/connect/api.go
@@ -5,6 +5,7 @@ package connect
import (
"context"
"database/sql"
+ "errors"
"net/http"
"time"
@@ -42,11 +43,61 @@ type Config struct {
Render func(http.ResponseWriter, *http.Request, string, string, int)
ReturnPath func(*http.Request) string
Now func() time.Time
+
+ // Unlinked and HomeOnly are optional and set together, or not at all;
+ // New refuses one without the other. With both nil, connect behaves
+ // exactly as it always has: an ordinary sign-in whose subject has no
+ // account link here is refused with the "unknown" page and the
+ // resume-linking marker. They exist for team mode (home/teammode),
+ // where a roster member who has never had a local account must be able
+ // to enter on their Home identity alone, as an addressless person.
+ //
+ // Unlinked is asked only during ordinary completion (never the link
+ // flow), only after the assertion has been verified and consumed, only
+ // for a subject with neither an account link nor a HomeOnly person, and
+ // only when no app session is present. It may create a person, and must
+ // do so only on a current decision that the subject may enter (in team
+ // mode: a roster Member decision whose lease is valid). It returns
+ // ErrNoPerson for a subject that may not enter, which connect answers
+ // exactly as it answers an unlinked subject without the hook; any
+ // other error is "cannot decide now", a 503.
+ Unlinked func(ctx context.Context, issuer, subject string) (Person, error)
+ // HomeOnly reads, never creates, the person Unlinked gave a subject;
+ // ErrNoPerson when there is none. Connect asks it after the account
+ // link, wherever it resolves a Home subject (Resolve, ResolveSession,
+ // completion), so the same-person rules hold for Home-only people too.
+ // A HomeOnly person has a positive ID and an empty Label: there is no
+ // address to give, and connect refuses a Home-only person with one.
+ HomeOnly func(ctx context.Context, issuer, subject string) (Person, error)
}
+// ErrNoPerson is what a Config.Unlinked or Config.HomeOnly hook returns for
+// "no person here for this subject", as distinct from a storage failure.
+var ErrNoPerson = errors.New("home connect: no person for this subject")
+
+// Resolve is the person a Home subject signs in as: an account link first,
+// then, when Config.HomeOnly is set, a Home-only person. It never creates
+// either. Its errors are linkstore's: ErrRefused for neither, ErrStorage
+// when that cannot be read.
func (b *Bridge) Resolve(ctx context.Context, subject string) (Person, error) {
id, label, err := b.links.Resolve(ctx, b.issuer, subject)
- return Person{ID: id, Label: label}, err
+ if err == nil || b.homeOnly == nil || !errors.Is(err, linkstore.ErrRefused) {
+ return Person{ID: id, Label: label}, err
+ }
+ p, err := b.homeOnly(ctx, b.issuer, subject)
+ return homeOnlyPerson(p, err)
+}
+
+// homeOnlyPerson holds a hook's answer to the Home-only contract: a
+// positive ID and no address, ErrNoPerson for none, anything else storage.
+func homeOnlyPerson(p Person, err error) (Person, error) {
+ switch {
+ case err == nil && p.ID > 0 && p.Label == "":
+ return p, nil
+ case err == nil || errors.Is(err, ErrNoPerson):
+ return Person{}, linkstore.ErrRefused
+ }
+ return Person{}, linkstore.ErrStorage
}
// Linked reports whether the local person already has a stored link to an
diff --git a/connect/bridge.go b/connect/bridge.go
index 40deb82..e35e5f5 100644
--- a/connect/bridge.go
+++ b/connect/bridge.go
@@ -33,6 +33,7 @@ type Bridge struct {
mintSession func(http.ResponseWriter, *http.Request, Session) error
localPerson func(context.Context, Session) (Person, error)
render func(http.ResponseWriter, *http.Request, string, string, int)
+ unlinked, homeOnly func(context.Context, string, string) (Person, error)
// rememberUnknown is set by NewRoutes: an assertion with no link here
// leaves the sealed navigation marker that resumes linking after the
// person signs in locally.
@@ -49,7 +50,7 @@ type homeFinishResult struct {
// Both subsystem schemas must be migrated before construction. The consumers
// share one replay store; choosing a different Finish cannot weaken freshness.
func New(c Config) (*Bridge, error) {
- if c.DB == nil || c.ReadSession == nil || c.MintHomeSession == nil || c.LookupLocalSession == nil || c.LookupPerson == nil || c.Render == nil || !validSessionCookie(c.SessionCookie) {
+ if c.DB == nil || c.ReadSession == nil || c.MintHomeSession == nil || c.LookupLocalSession == nil || c.LookupPerson == nil || c.Render == nil || !validSessionCookie(c.SessionCookie) || (c.Unlinked == nil) != (c.HomeOnly == nil) {
return nil, errHomeBridge
}
sealer, err := seal.New(c.DEK, c.Namespace)
@@ -68,7 +69,7 @@ func New(c Config) (*Bridge, error) {
if now == nil {
now = time.Now
}
- b := &Bridge{namespace: c.Namespace, keyHash: sha256.Sum256(c.DEK), origin: c.Origin, issuer: c.Issuer, sessionCookie: c.SessionCookie, links: linker, now: now, returnPath: c.ReturnPath, readSession: c.ReadSession, mintSession: c.MintHomeSession, localPerson: c.LookupLocalSession, render: c.Render}
+ b := &Bridge{namespace: c.Namespace, keyHash: sha256.Sum256(c.DEK), origin: c.Origin, issuer: c.Issuer, sessionCookie: c.SessionCookie, links: linker, now: now, returnPath: c.ReturnPath, readSession: c.ReadSession, mintSession: c.MintHomeSession, localPerson: c.LookupLocalSession, render: c.Render, unlinked: c.Unlinked, homeOnly: c.HomeOnly}
cfg := handoff.ConsumerConfig{Store: exchange, ConsumerID: c.ConsumerID, Complete: b.complete, Fail: b.fail, Now: func() time.Time { return b.now() }, CurrentSubject: func(r *http.Request) string {
result, _ := r.Context().Value(homeFinishKey{}).(*homeFinishResult)
if result != nil && result.session != nil && result.session.Method == HomeMethod {
@@ -209,7 +210,21 @@ func (b *Bridge) complete(w http.ResponseWriter, r *http.Request, claims asserti
setHomeCookie(w, homeProofCookie, secret, 300)
return nil
}
- id, _, err := b.links.Resolve(r.Context(), claims.Issuer, claims.Subject)
+ // The exchange verified the issuer; an assertion from any other is
+ // treated as an unlinked subject, as linkstore always has.
+ arriving, err := Person{}, error(linkstore.ErrRefused)
+ if claims.Issuer == b.issuer {
+ arriving, err = b.Resolve(r.Context(), claims.Subject)
+ }
+ if errors.Is(err, linkstore.ErrRefused) && b.unlinked != nil && result.session == nil && claims.Issuer == b.issuer {
+ // Nobody is signed in here and the subject has no person: the one
+ // place a person may be created from a Home subject alone. With a
+ // session present the arrival is refused below as unknown, before
+ // anything is allocated, whoever that session belongs to.
+ // ErrStorage ("cannot decide now") falls through to errHomeBridge,
+ // which the exchange answers 503.
+ arriving, err = homeOnlyPerson(b.unlinked(r.Context(), claims.Issuer, claims.Subject))
+ }
if errors.Is(err, linkstore.ErrRefused) {
if b.rememberUnknown != nil {
b.rememberUnknown(w)
@@ -221,7 +236,7 @@ func (b *Bridge) complete(w http.ResponseWriter, r *http.Request, claims asserti
}
if result.session != nil {
person, err := b.existingPerson(r, *result.session)
- if err != nil || person.ID != id {
+ if err != nil || person.ID != arriving.ID {
return rejectHome(r, "failed", http.StatusForbidden)
}
}
diff --git a/connect/bridge_test.go b/connect/bridge_test.go
index c97ff6a..08239fd 100644
--- a/connect/bridge_test.go
+++ b/connect/bridge_test.go
@@ -56,6 +56,13 @@ type bridgeFixture struct {
}
func newBridgeFixture(t *testing.T) *bridgeFixture {
+ t.Helper()
+ return newBridgeFixtureWith(t, nil)
+}
+
+// newBridgeFixtureWith lets a test adjust the Config before New, with the
+// fixture's database already migrated.
+func newBridgeFixtureWith(t *testing.T, adjust func(*bridgeFixture, *Config)) *bridgeFixture {
t.Helper()
d, e := sql.Open("sqlite", filepath.Join(t.TempDir(), "connect.db")+"?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)")
if e != nil {
@@ -116,6 +123,9 @@ func newBridgeFixture(t *testing.T) *bridgeFixture {
w.WriteHeader(status)
w.Write([]byte(state))
}}
+ if adjust != nil {
+ adjust(f, &cfg)
+ }
f.b, e = New(cfg)
if e != nil {
t.Fatal(e)
diff --git a/connect/unlinked_test.go b/connect/unlinked_test.go
new file mode 100644
index 0000000..99ba7ba
--- /dev/null
+++ b/connect/unlinked_test.go
@@ -0,0 +1,267 @@
+package connect
+
+import (
+ "context"
+ "database/sql"
+ "errors"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "time"
+)
+
+// homeOnlyHooks is a team-mode app in miniature: a Home-only person table,
+// and a decision a test sets (admit, refuse, or cannot decide). It counts
+// how often each hook is asked, so a test can prove when connect does not
+// ask at all.
+type homeOnlyHooks struct {
+ db *sql.DB
+ decision error // nil admits; ErrNoPerson refuses; anything else is unavailable
+ label string
+ lookupErr error
+ unlinked int
+ homeOnly int
+ remember int
+}
+
+func (h *homeOnlyHooks) install(f *bridgeFixture, c *Config) {
+ h.db = f.db
+ if _, err := f.db.Exec("CREATE TABLE home_only(id INTEGER PRIMARY KEY AUTOINCREMENT, issuer TEXT NOT NULL, subject TEXT NOT NULL, UNIQUE(issuer,subject)); INSERT INTO sqlite_sequence(name,seq) VALUES('home_only',1000)"); err != nil {
+ panic(err)
+ }
+ c.HomeOnly = func(ctx context.Context, issuer, subject string) (Person, error) {
+ h.homeOnly++
+ if h.lookupErr != nil {
+ return Person{}, h.lookupErr
+ }
+ var p Person
+ err := h.db.QueryRowContext(ctx, "SELECT id FROM home_only WHERE issuer=? AND subject=?", issuer, subject).Scan(&p.ID)
+ if errors.Is(err, sql.ErrNoRows) {
+ return Person{}, ErrNoPerson
+ }
+ p.Label = h.label
+ return p, err
+ }
+ c.Unlinked = func(ctx context.Context, issuer, subject string) (Person, error) {
+ h.unlinked++
+ if h.decision != nil {
+ return Person{}, h.decision
+ }
+ res, err := h.db.ExecContext(ctx, "INSERT INTO home_only(issuer,subject) VALUES(?,?)", issuer, subject)
+ if err != nil {
+ return Person{}, err
+ }
+ id, err := res.LastInsertId()
+ return Person{ID: id, Label: h.label}, err
+ }
+}
+
+func newHomeOnlyFixture(t *testing.T) (*bridgeFixture, *homeOnlyHooks) {
+ t.Helper()
+ h := &homeOnlyHooks{}
+ f := newBridgeFixtureWith(t, h.install)
+ f.b.rememberUnknown = func(http.ResponseWriter) { h.remember++ }
+ return f, h
+}
+
+func (h *homeOnlyHooks) count(t *testing.T) int {
+ t.Helper()
+ var n int
+ if err := h.db.QueryRow("SELECT COUNT(*) FROM home_only").Scan(&n); err != nil {
+ t.Fatal(err)
+ }
+ return n
+}
+
+// finishAs runs one ordinary exchange for subject with cookies present.
+func (f *bridgeFixture) finishAs(t *testing.T, subject string, cookies []*http.Cookie) *httptest.ResponseRecorder {
+ t.Helper()
+ pending, nonce := f.start(t, cookies, "/next")
+ inbox := f.callback(t, subject, nonce, time.Now().Add(-time.Minute))
+ w := httptest.NewRecorder()
+ f.b.Finish(w, bridgeRequest(http.MethodGet, "/auth/finish", append(append([]*http.Cookie{}, cookies...), pending, inbox)))
+ return w
+}
+
+func TestUnlinkedHooksAreAPair(t *testing.T) {
+ hook := func(context.Context, string, string) (Person, error) { return Person{}, ErrNoPerson }
+ newBridgeFixtureWith(t, func(_ *bridgeFixture, c *Config) {
+ for name, adjust := range map[string]func(*Config){
+ "unlinked only": func(c *Config) { c.Unlinked = hook },
+ "home-only only": func(c *Config) { c.HomeOnly = hook },
+ } {
+ one := *c
+ adjust(&one)
+ if _, err := New(one); err == nil {
+ t.Errorf("%s: New accepted one hook without the other", name)
+ }
+ }
+ both := *c
+ both.Unlinked, both.HomeOnly = hook, hook
+ if _, err := New(both); err != nil {
+ t.Errorf("New refused both hooks: %v", err)
+ }
+ })
+}
+
+func TestUnlinkedMemberSignsInAsAHomeOnlyPerson(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ w := f.finishAs(t, "pr_member", nil)
+ if w.Code != 303 || w.Header().Get("Location") != "/next" {
+ t.Fatalf("finish=%d %q body=%s", w.Code, w.Header().Get("Location"), w.Body.String())
+ }
+ if h.unlinked != 1 || h.count(t) != 1 {
+ t.Fatalf("unlinked asked %d times, %d people", h.unlinked, h.count(t))
+ }
+ cookie := bridgeCookie(t, w, f.b.sessionCookie)
+ r := bridgeRequest(http.MethodGet, "/", []*http.Cookie{cookie})
+ s, _ := f.sessions.From(r)
+ if s.Method != HomeMethod || s.Subject != "pr_member" {
+ t.Fatalf("session %+v", s)
+ }
+ p, err := f.b.ResolveSession(r)
+ if err != nil || p.ID <= 1000 || p.Label != "" {
+ t.Fatalf("ResolveSession %+v %v", p, err)
+ }
+ // A second sign-in is the same person, found without asking Unlinked.
+ again := f.finishAs(t, "pr_member", nil)
+ if again.Code != 303 || h.unlinked != 1 || h.count(t) != 1 {
+ t.Fatalf("second sign-in=%d unlinked=%d people=%d", again.Code, h.unlinked, h.count(t))
+ }
+ if p2, err := f.b.Resolve(context.Background(), "pr_member"); err != nil || p2.ID != p.ID {
+ t.Fatal("Resolve does not find the Home-only person", err)
+ }
+ // Signed in as that person, the same subject arriving again is fine.
+ own := f.finishAs(t, "pr_member", []*http.Cookie{cookie})
+ if own.Code != 303 || h.unlinked != 1 {
+ t.Fatalf("same person over own session=%d", own.Code)
+ }
+}
+
+func TestUnlinkedRefusalIsConnectsUnknown(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ h.decision = ErrNoPerson
+ w := f.finishAs(t, "pr_stranger", nil)
+ if w.Code != 403 || w.Body.String() != "unknown" || h.remember != 1 {
+ t.Fatalf("refused=%d %q remember=%d", w.Code, w.Body.String(), h.remember)
+ }
+ bridgeNoSession(t, f.b, w)
+ if h.count(t) != 0 {
+ t.Fatal("refusal allocated a person")
+ }
+}
+
+func TestUnlinkedUndecidedIsRetryable(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ h.decision = errors.New("roster unknown")
+ w := f.finishAs(t, "pr_member", nil)
+ if w.Code != 503 || w.Body.String() != "failed" || h.remember != 0 {
+ t.Fatalf("undecided=%d %q remember=%d", w.Code, w.Body.String(), h.remember)
+ }
+ bridgeNoSession(t, f.b, w)
+ if h.count(t) != 0 {
+ t.Fatal("undecided allocated a person")
+ }
+ h.decision = nil
+ h.lookupErr = errors.New("disk")
+ w = f.finishAs(t, "pr_member", nil)
+ if w.Code != 503 || h.unlinked != 1 {
+ t.Fatalf("unreadable Home-only store=%d unlinked=%d", w.Code, h.unlinked)
+ }
+ bridgeNoSession(t, f.b, w)
+}
+
+// An addressless person is the contract: a hook handing back a label (an
+// address) is refused, never minted.
+func TestUnlinkedPersonWithAnAddressIsRefused(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ h.label = "someone@example.com"
+ w := f.finishAs(t, "pr_member", nil)
+ if w.Code != 403 || w.Body.String() != "unknown" {
+ t.Fatalf("labelled Home-only person=%d %q", w.Code, w.Body.String())
+ }
+ bridgeNoSession(t, f.b, w)
+ if _, err := f.b.Resolve(context.Background(), "pr_member"); err == nil {
+ t.Fatal("Resolve accepted a Home-only person with an address")
+ }
+}
+
+// Somebody already signed in: an unknown arrival is refused before anything
+// is allocated, and Unlinked is never asked.
+func TestUnlinkedNeverAskedOverALiveSession(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ local := f.local(t, "x@example.com", "magiclink", time.Now().Add(-time.Minute))
+ w := f.finishAs(t, "pr_member", []*http.Cookie{local})
+ if w.Code != 403 || h.unlinked != 0 || h.count(t) != 0 {
+ t.Fatalf("arrival over a live session=%d unlinked=%d people=%d", w.Code, h.unlinked, h.count(t))
+ }
+ bridgeNoSession(t, f.b, w)
+}
+
+// Connect's same-person rule holds for Home-only people: a known Home-only
+// member arriving over somebody else's live session is 403, and that
+// session survives.
+func TestKnownHomeOnlyArrivalOverAnotherSessionIsRefused(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ if w := f.finishAs(t, "pr_member", nil); w.Code != 303 {
+ t.Fatalf("allocate=%d", w.Code)
+ }
+ local := f.local(t, "x@example.com", "magiclink", time.Now().Add(-time.Minute))
+ w := f.finishAs(t, "pr_member", []*http.Cookie{local})
+ if w.Code != 403 || w.Body.String() != "failed" {
+ t.Fatalf("known arrival over another session=%d %q", w.Code, w.Body.String())
+ }
+ bridgeNoSession(t, f.b, w)
+ if s, ok := f.sessions.From(bridgeRequest(http.MethodGet, "/", []*http.Cookie{local})); !ok || s.Subject != "x@example.com" {
+ t.Fatal("the live local session changed")
+ }
+ if h.unlinked != 1 {
+ t.Fatal("Unlinked asked again")
+ }
+}
+
+// A linked subject is the linked account: HomeOnly is not consulted and
+// nothing is allocated, and the link flow never reaches Unlinked.
+func TestLinkedSubjectNeverReachesTheHooks(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ local := f.local(t, "one@example.com", "magiclink", time.Now().Add(-time.Minute))
+ f.link(t, local, "pr_linked")
+ if h.unlinked != 0 {
+ t.Fatal("the link flow asked Unlinked")
+ }
+ before := h.homeOnly
+ w := f.finishAs(t, "pr_linked", nil)
+ if w.Code != 303 || h.unlinked != 0 || h.homeOnly != before || h.count(t) != 0 {
+ t.Fatalf("linked sign-in=%d unlinked=%d homeOnly=%d", w.Code, h.unlinked, h.homeOnly-before)
+ }
+ p, err := f.b.ResolveSession(bridgeRequest(http.MethodGet, "/", []*http.Cookie{bridgeCookie(t, w, f.b.sessionCookie)}))
+ if err != nil || p.Label != "one@example.com" {
+ t.Fatal("linked identity changed", err)
+ }
+}
+
+// Malformed cookies are still connect's refusals with the hooks set: the
+// shape checks are shared, and none reaches Unlinked.
+func TestUnlinkedKeepsConnectsCookieChecks(t *testing.T) {
+ f, h := newHomeOnlyFixture(t)
+ pending, nonce := f.start(t, nil, "/")
+ inbox := f.callback(t, "pr_member", nonce, time.Now().Add(-time.Minute))
+ bad := strings.Repeat("A", 43)
+ for name, cookies := range map[string][]*http.Cookie{
+ "unreadable session": {{Name: f.b.sessionCookie, Value: bad}},
+ "duplicate session": {{Name: f.b.sessionCookie, Value: bad}, {Name: f.b.sessionCookie, Value: bad}},
+ "malformed init": {{Name: homeInitCookie, Value: "bad"}},
+ "malformed proof": {{Name: homeProofCookie, Value: "bad"}},
+ } {
+ w := httptest.NewRecorder()
+ f.b.Finish(w, bridgeRequest(http.MethodGet, "/auth/finish", append(cookies, pending, inbox)))
+ if w.Code == 303 {
+ t.Fatalf("%s: minted", name)
+ }
+ bridgeNoSession(t, f.b, w)
+ }
+ if h.unlinked != 0 || h.count(t) != 0 {
+ t.Fatal("a malformed cookie reached Unlinked")
+ }
+}