oficina / base Public

Add app sign-out and link every inner page back to Home

consumer mounts POST /auth/signout: CSRF-protected by the app's guard, it
ends the app's own session (the row is revoked, not just the cookie).
Scratchpad and Welcome show "Sign out of {App}". It lands on a shared
signed-out page with "Sign in again" and "Back to Home" rather than on the
app's /: signed out, / redirects on to Base, and the app's CSP
form-action 'self' covers the form's whole redirect chain, so Chromium
refused that hop and left the old, signed-in-looking page on screen
(seen in the new browser test; rastrillo's Keymail flow stays on-origin
for the same reason). Base's Settings button now reads "Sign out of
Base", with a line saying apps stay signed in (R30).

The "base" wordmark on People, Store, Settings and Uninstall links to /,
and in the installed apps to BASE_APP_ISSUER + "/".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 3dac3cb613c5753a2dbac8859f5b4100c6f367d7 parent 9d780f9
17 files changed, +279 −15
  • docs/copy-pending.md +11 −1
  • internal/browsertest/apps_test.go +84 −0
  • internal/browsertest/world_test.go +1 −1
  • internal/consumer/consumer.go +56 −1
  • internal/consumer/consumer_test.go +46 −0
  • internal/consumer/templates/signedout.html +10 −0
  • internal/look/static/app.css +3 −0
  • internal/scratchpad/README.md +7 −1
  • internal/scratchpad/scratchpad.go +5 −3
  • internal/scratchpad/scratchpad_test.go +21 −0
  • internal/scratchpad/templates/notes.html +2 −1
  • internal/web/templates/people.html +1 −1
  • internal/web/templates/settings.html +3 −2
  • internal/web/templates/store.html +1 −1
  • internal/web/templates/uninstall.html +1 −1
  • internal/webtest/settings_test.go +24 −0
  • internal/welcome/templates/welcome.html +3 −2
diff --git a/docs/copy-pending.md b/docs/copy-pending.md
index 595a881..2ac77c2 100644
--- a/docs/copy-pending.md
+++ b/docs/copy-pending.md
@@ -93,7 +93,8 @@ People and invitations:
| internal/web/templates/settings.html | Settings heading | Settings |
| internal/web/templates/settings.html | Settings label | Base name |
| internal/web/templates/settings.html | Settings label | Signed in as |
-| internal/web/templates/settings.html | Settings button | Sign out |
+| internal/web/templates/settings.html | Settings button (R30: says it is Base's only) | Sign out of Base |
+| internal/web/templates/settings.html | Line under the sign-out button | This signs you out of Base only. Apps you've opened stay signed in until you sign out of each one. |
Handing a member to an installed app (`GET /authorize`):
@@ -132,6 +133,15 @@ Installed apps: the shared sign-in (`internal/consumer`), Scratchpad and Welcome
| internal/welcome/templates/welcome.html | Welcome page, lead | This is {Base name} on Base. Your team's apps are on Home. |
| internal/welcome/templates/welcome.html | Link back to Base | Back to Home |
| internal/welcome/welcome.go | Page failed to render (500) | something went wrong |
+| internal/scratchpad/templates/notes.html | Sign-out button | Sign out of Scratchpad |
+| internal/welcome/templates/welcome.html | Sign-out button | Sign out of Welcome |
+| internal/consumer/templates/signedout.html | Signed-out page (both apps), title | Signed out |
+| internal/consumer/templates/signedout.html | Signed-out page, heading | You're signed out |
+| internal/consumer/templates/signedout.html | Signed-out page, lead | You've signed out of this app. Base and your other apps aren't affected. |
+| internal/consumer/templates/signedout.html | Signed-out page, button | Sign in again |
+| internal/consumer/templates/signedout.html | Signed-out page, link to Base | Back to Home |
+| internal/consumer/consumer.go | Signed-out page failed to render (500) | something went wrong |
+| internal/scratchpad/README.md | Sign-out and refused-save paragraphs | A sign-in lasts 12 hours [...] Save again to replace their version. |
"Signed in as {name}, {Base name}" on Scratchpad is the spec's own wording (5.8). When Base has no name for a person, their email stands in for {name}.
diff --git a/internal/browsertest/apps_test.go b/internal/browsertest/apps_test.go
new file mode 100644
index 0000000..583eb78
--- /dev/null
+++ b/internal/browsertest/apps_test.go
@@ -0,0 +1,84 @@
+//go:build browser
+
+package browsertest
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/chromedp/chromedp"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+
+ "amadan.net/carlos/base/internal/consumer"
+)
+
+// count is how many requests to path with method an app received.
+func count(rec *recorder, method, path string) int {
+ n := 0
+ for _, r := range rec.all() {
+ if r.method == method && r.path == path {
+ n++
+ }
+ }
+ return n
+}
+
+// Findings 7 and 8, in the browser: each installed app's wordmark goes back
+// to Base's Home, and each app has its own Sign out. Signing out of
+// Scratchpad lands on its signed-out page; signing in again from there is a
+// fresh handoff, so the app then shows whoever Base vouches for now.
+func TestInstalledAppsLinkHomeAndSignOut(t *testing.T) {
+ w := newWorld(t)
+ signInByEmail(t, w.rig, w.baseOrigin, w.base.mail)
+
+ note := chromedp.CSS(`textarea[name="note"]`)
+ drive(t, w.rig, chromedp.Click(chromedp.CSS(fmt.Sprintf(`a.app[href=%q]`, w.padOrigin+"/"))), chromedp.WaitVisible(note))
+ if got := harness.Evaluate[string](w.rig, `document.querySelector(".crumb a.wordmark").href`); got != w.baseOrigin+"/" {
+ t.Errorf("Scratchpad's wordmark links to %q, want %s/", got, w.baseOrigin)
+ }
+ signOut := chromedp.CSS(`form[action="/auth/signout"] button[type="submit"]`)
+ if got := harness.Evaluate[string](w.rig, `document.querySelector('form[action="/auth/signout"] button').textContent`); got != "Sign out of Scratchpad" {
+ t.Errorf("Scratchpad's sign-out button says %q", got)
+ }
+ // Signing out lands on the app's own signed-out page: the form's
+ // redirect chain stays on Scratchpad's origin, as its CSP requires.
+ again := chromedp.CSS(`a.btn[href="/"]`)
+ drive(t, w.rig, chromedp.Click(signOut), chromedp.WaitVisible(again))
+ w.rig.Screen("main", "signed out of Scratchpad")
+ if here := harness.Read(w.rig, chromedp.Location()); here != w.padOrigin+consumer.SignedOutPath {
+ t.Fatalf("signing out ended at %s", here)
+ }
+ if n := count(w.pad, "POST", consumer.SignOutPath); n != 1 {
+ t.Errorf("Scratchpad got %d sign-out POSTs, want 1", n)
+ }
+ // Signing in again is a fresh handoff from Base.
+ drive(t, w.rig, chromedp.Click(again), chromedp.WaitVisible(note))
+ if n := count(w.pad, "POST", consumer.AssertionPath); n != 2 {
+ t.Errorf("Scratchpad got %d assertion POSTs, want a second one after signing in again", n)
+ }
+ if here := harness.Read(w.rig, chromedp.Location()); here != w.padOrigin+"/" {
+ t.Errorf("signing in again ended at %s", here)
+ }
+
+ welcomeTile := chromedp.CSS(fmt.Sprintf(`a.app[href=%q]`, w.welcomeOrigin+"/"))
+ drive(t, w.rig, chromedp.Click(chromedp.CSS(".crumb a.wordmark")), chromedp.WaitVisible(welcomeTile))
+ if here := harness.Read(w.rig, chromedp.Location()); here != w.baseOrigin+"/" {
+ t.Fatalf("Scratchpad's wordmark went to %s, want Base's Home", here)
+ }
+
+ drive(t, w.rig, chromedp.Click(welcomeTile), chromedp.WaitVisible(signOut))
+ w.rig.Screen("main", "Welcome")
+ if got := harness.Evaluate[string](w.rig, `document.querySelector('form[action="/auth/signout"] button').textContent`); got != "Sign out of Welcome" {
+ t.Errorf("Welcome's sign-out button says %q", got)
+ }
+ if got := harness.Evaluate[string](w.rig, `document.querySelector(".crumb a.wordmark").href`); got != w.baseOrigin+"/" {
+ t.Errorf("Welcome's wordmark links to %q, want %s/", got, w.baseOrigin)
+ }
+
+ // Base's own inner pages link Home too.
+ drive(t, w.rig, chromedp.Navigate(w.baseOrigin+"/people"), chromedp.Click(chromedp.CSS(".crumb a.wordmark")), chromedp.WaitVisible(welcomeTile))
+ if here := harness.Read(w.rig, chromedp.Location()); here != w.baseOrigin+"/" {
+ t.Errorf("People's wordmark went to %s", here)
+ }
+}
diff --git a/internal/browsertest/world_test.go b/internal/browsertest/world_test.go
index b60ba4c..0061c75 100644
--- a/internal/browsertest/world_test.go
+++ b/internal/browsertest/world_test.go
@@ -133,7 +133,7 @@ func newWorld(t *testing.T) *world {
cfg := baseConfig(fmt.Sprintf("https://base.localhost:%d", port))
cfg.AppsDomain = fmt.Sprintf("localhost:%d", port)
cfg.AssertionKey = key
- w := &world{t: t, base: newBase(t, cfg), baseOrigin: cfg.Origin, pad: newRecorder(consumer.AssertionPath, consumer.FinishPath)}
+ w := &world{t: t, base: newBase(t, cfg), baseOrigin: cfg.Origin, pad: newRecorder(consumer.AssertionPath, consumer.FinishPath, consumer.SignOutPath)}
hosts.add("base.localhost:"+fmt.Sprint(port), w.base.handler)
ctx := context.Background()
diff --git a/internal/consumer/consumer.go b/internal/consumer/consumer.go
index 14b81a4..c278d37 100644
--- a/internal/consumer/consumer.go
+++ b/internal/consumer/consumer.go
@@ -18,6 +18,9 @@
// assertion's ID is recorded so it can never be used again. Only then is
// the session started.
//
+// POST /auth/signout ends the app's own session, and nothing else, and
+// lands on GET /auth/signed-out.
+//
// An assertion says who the person is. It grants nothing: each app decides
// what that person may do.
package consumer
@@ -35,6 +38,7 @@ import (
"errors"
"fmt"
"io"
+ "io/fs"
"log/slog"
"math"
"mime"
@@ -49,6 +53,8 @@ import (
"amadan.net/rastrillo/rastrillo/assertion"
"amadan.net/rastrillo/rastrillo/migrate"
"amadan.net/rastrillo/rastrillo/sessions"
+
+ "amadan.net/carlos/base/internal/look"
)
// The handoff's routes.
@@ -56,6 +62,10 @@ const (
StartPath = "/auth/start"
AssertionPath = "/auth/assertion"
FinishPath = "/auth/finish"
+ // SignOutPath ends the app's own session (POST, same origin).
+ SignOutPath = "/auth/signout"
+ // SignedOutPath is the page sign-out lands on.
+ SignedOutPath = "/auth/signed-out"
)
const (
@@ -86,6 +96,9 @@ var (
//go:embed migrations/*.sql
var migrationFS embed.FS
+//go:embed templates/*.html
+var templateFS embed.FS
+
// Schema is the handoff's tables. Apply it with sessions.Schema before Mount.
var Schema = migrate.MustFromFS(migrationFS, "consumer")
@@ -161,6 +174,7 @@ type handoff struct {
sess *sessions.Sessions
host string
logger *slog.Logger
+ pages *look.Renderer
}
// Mount adds the handoff to r: a middleware that puts the signed-in person
@@ -168,6 +182,12 @@ type handoff struct {
// r (chi requires middleware first). db is the writer handle with Schema
// applied; sess must be built for cfg.Origin on the same database.
//
+// POST /auth/signout ends the app's session and sends the browser to
+// GET /auth/signed-out, a page that says so, with a link to sign in again
+// and one back to Base's Home. It relies on the app's CSRF guard, which it
+// does not exempt. It signs out of this app only: Base, and other apps,
+// keep theirs.
+//
// POST /auth/assertion arrives from Base's page, so the app's CSRF guard must
// exempt it, as csrf.Protect(origin, csrf.Exempt(consumer.AssertionPath))
// does. That handler makes its own, stricter check: Origin must be exactly
@@ -185,11 +205,21 @@ func Mount(r chi.Router, db *sql.DB, cfg Config, sess *sessions.Sessions) {
if logger == nil {
logger = slog.Default()
}
- h := &handoff{db: db, cfg: cfg, sess: sess, host: strings.TrimPrefix(cfg.Origin, "https://"), logger: logger}
+ sub, err := fs.Sub(templateFS, "templates")
+ if err != nil {
+ panic("consumer.Mount: " + err.Error())
+ }
+ pages, err := look.NewRenderer(sub, nil)
+ if err != nil {
+ panic("consumer.Mount: " + err.Error())
+ }
+ h := &handoff{db: db, cfg: cfg, sess: sess, host: strings.TrimPrefix(cfg.Origin, "https://"), logger: logger, pages: pages}
r.Use(h.identify)
r.Get(StartPath, h.start)
r.Post(AssertionPath, h.assertion)
r.Get(FinishPath, h.finish)
+ r.Post(SignOutPath, h.signOut)
+ r.Get(SignedOutPath, h.signedOut)
}
type ctxKey struct{}
@@ -424,6 +454,31 @@ func (h *handoff) finish(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, to, http.StatusSeeOther)
}
+// signOut ends this browser's session here. Signing in again starts a fresh
+// handoff, so whoever Base vouches for then is who the app sees.
+func (h *handoff) signOut(w http.ResponseWriter, r *http.Request) {
+ if !h.guard(w, r) {
+ return
+ }
+ h.sess.SignOut(w, r)
+ // Not straight to "/": signed out, that redirects on to Base, and the
+ // app's CSP form-action 'self' covers this form's whole redirect chain,
+ // so the browser would refuse the hop and leave the old page showing.
+ // The signed-out page's links are plain navigations.
+ http.Redirect(w, r, SignedOutPath, http.StatusSeeOther)
+}
+
+// signedOut says the person has left this app, and offers the way back in.
+func (h *handoff) signedOut(w http.ResponseWriter, r *http.Request) {
+ if !h.guard(w, r) {
+ return
+ }
+ if err := h.pages.Page(w, "signedout", struct{ Home string }{h.cfg.Issuer + "/"}); err != nil {
+ h.logger.Error("consumer: render signed-out page", "err", err)
+ http.Error(w, "something went wrong", http.StatusInternalServerError)
+ }
+}
+
func digest(s string) string { sum := sha256.Sum256([]byte(s)); return hex.EncodeToString(sum[:]) }
func jtiHash(c assertion.Claims) string { return digest(c.Issuer + "\x00" + c.ID) }
diff --git a/internal/consumer/consumer_test.go b/internal/consumer/consumer_test.go
index b2a2035..e729a7e 100644
--- a/internal/consumer/consumer_test.go
+++ b/internal/consumer/consumer_test.go
@@ -680,3 +680,49 @@ func TestStorageErrorKeepsItsCause(t *testing.T) {
}
}
}
+
+// Finding 7 (R30): an app's own sign-out ends its session for good, and
+// then a different person can sign in on that browser.
+func TestSignOutEndsTheAppSession(t *testing.T) {
+ a := newApp(t)
+ b := a.browser()
+ b.signIn(paul, "/")
+ if r := b.post(SignOutPath, url.Values{}, "https://evil.test"); r.Code != http.StatusForbidden {
+ t.Fatalf("cross-origin sign-out: %d, want 403", r.Code)
+ }
+ if r := b.get("/"); r.Code != 200 {
+ t.Fatalf("a refused sign-out signed out: %d", r.Code)
+ }
+ // A copy of the session cookie, as a second tab or a thief would hold.
+ u, _ := url.Parse(appOrigin)
+ stolen := b.client.Jar.Cookies(u)
+ // Same origin: a 303 off this origin would break the form's redirect
+ // chain on the app's CSP form-action 'self'.
+ r := b.post(SignOutPath, url.Values{}, appOrigin)
+ if r.Code != http.StatusSeeOther || r.Location() != SignedOutPath {
+ t.Fatalf("sign-out: %d %q %s", r.Code, r.Location(), r.Body)
+ }
+ page := b.get(SignedOutPath)
+ if page.Code != 200 || page.Header.Get("Cache-Control") != "no-store" {
+ t.Fatalf("signed-out page: %d %q", page.Code, page.Header.Get("Cache-Control"))
+ }
+ for _, want := range []string{`<a class="btn" href="/">Sign in again</a>`, `href="` + issuerOrigin + `/">Back to Home</a>`, `<a class="wordmark" href="` + issuerOrigin + `/">base</a>`} {
+ if !strings.Contains(page.Body, want) {
+ t.Errorf("signed-out page lacks %q:\n%s", want, page.Body)
+ }
+ }
+ b.signedOut()
+ replay := a.browser()
+ replay.client.Jar.SetCookies(u, stolen)
+ replay.signedOut()
+ // Base now vouches for someone else on this browser; they get in as
+ // themselves.
+ ana := person{"member-ana", "Ana", "ana@acme.test", "Acme Ltd"}
+ b.signIn(ana, "/")
+ if r := b.get("/"); r.Body != "Signed in as Ana, Acme Ltd (member-ana)" {
+ t.Errorf("after signing out and in again: %q", r.Body)
+ }
+ if r := b.get(SignOutPath); r.Code != http.StatusMethodNotAllowed {
+ t.Errorf("GET sign-out: %d, want 405", r.Code)
+ }
+}
diff --git a/internal/consumer/templates/signedout.html b/internal/consumer/templates/signedout.html
new file mode 100644
index 0000000..42e3d2a
--- /dev/null
+++ b/internal/consumer/templates/signedout.html
@@ -0,0 +1,10 @@
+{{define "title"}}Signed out{{end}}
+{{define "main"}}<main class="inner">
+<div class="sheet glass">
+<div class="crumb"><a class="wordmark" href="{{.Home}}">base</a></div>
+<h2>You're signed out</h2>
+<p class="lead">You've signed out of this app. Base and your other apps aren't affected.</p>
+<div class="actions"><a class="btn" href="/">Sign in again</a>
+<a class="btn ghost" href="{{.Home}}">Back to Home</a></div>
+</div>
+</main>{{end}}
diff --git a/internal/look/static/app.css b/internal/look/static/app.css
index 8966375..3b2ae46 100644
--- a/internal/look/static/app.css
+++ b/internal/look/static/app.css
@@ -161,6 +161,9 @@ button.alt[aria-busy="true"] { cursor: progress; }
/* Links drawn as tiles and buttons. */
a.app, a.me { color: inherit; text-decoration: none; }
+/* The wordmark on inner pages is the way back to Home: a 44px target. */
+a.wordmark { color: inherit; text-decoration: none; min-height: 44px; border-radius: 8px; }
+.notepad + form { margin-top: 16px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.ask:disabled { cursor: not-allowed; font: inherit; font-size: 14px; }
diff --git a/internal/scratchpad/README.md b/internal/scratchpad/README.md
index 76c518f..9bf4cf3 100644
--- a/internal/scratchpad/README.md
+++ b/internal/scratchpad/README.md
@@ -13,7 +13,13 @@ member of that Base sees the same note and can change it. (CARLOS app spec
1.7: Base says who someone is, and each app decides what they may do.)
A sign-in lasts 12 hours, so people stay signed in while Base is briefly
-down, and someone removed from Base loses access within a day.
+down, and someone removed from Base loses access within a day. **Sign out of
+Scratchpad** ends it sooner. That signs you out of Scratchpad only: you stay
+signed in to Base, and **Sign in again** brings you straight back.
+
+Two people can edit the note at once. If someone else saved while you were
+typing, your save is refused and your text stays on the page, so nothing is
+lost. Save again to replace their version.
## Settings
diff --git a/internal/scratchpad/scratchpad.go b/internal/scratchpad/scratchpad.go
index 1e9878d..1d1e744 100644
--- a/internal/scratchpad/scratchpad.go
+++ b/internal/scratchpad/scratchpad.go
@@ -51,6 +51,7 @@ const (
)
type app struct {
+ home string // Base's Home, where the wordmark links
db *sql.DB
pages *look.Renderer
logger *slog.Logger
@@ -80,7 +81,7 @@ func App(d *db.DB, cfg consumer.Config, logger *slog.Logger) (http.Handler, erro
if err != nil {
return nil, err
}
- a := &app{db: d.Writer(), pages: pages, logger: logger}
+ a := &app{home: cfg.Issuer + "/", db: d.Writer(), pages: pages, logger: logger}
r := chi.NewRouter()
// Base's form posts the assertion cross-origin; that one handler checks
@@ -98,8 +99,8 @@ func App(d *db.DB, cfg consumer.Config, logger *slog.Logger) (http.Handler, erro
}
type notesPage struct {
- Name, Base, Note string
- Revision int64 // the revision the form edits
+ Home, Name, Base, Note string
+ Revision int64 // the revision the form edits
// Conflict is set when a save was refused because someone saved first:
// Note is then the refused text and Saved the note as it stands.
Conflict bool
@@ -131,6 +132,7 @@ func (a *app) notes(w http.ResponseWriter, r *http.Request) {
}
func (a *app) page(w http.ResponseWriter, status int, p notesPage) {
+ p.Home = a.home
if err := a.pages.PageStatus(w, status, "notes", p); err != nil {
a.logger.Error("scratchpad: render", "err", err)
http.Error(w, "something went wrong", http.StatusInternalServerError)
diff --git a/internal/scratchpad/scratchpad_test.go b/internal/scratchpad/scratchpad_test.go
index d9ba617..3262600 100644
--- a/internal/scratchpad/scratchpad_test.go
+++ b/internal/scratchpad/scratchpad_test.go
@@ -309,3 +309,24 @@ func TestStaleSaveIsRefused(t *testing.T) {
t.Errorf("save without a revision: %d", r.Code)
}
}
+
+// Findings 7 and 8: Scratchpad links back to Base's Home, and signs out of
+// itself onto the shared signed-out page.
+func TestScratchpadLinksHomeAndSignsOut(t *testing.T) {
+ p := newPad(t)
+ b := p.browser()
+ b.signIn("member-paul", "Paul", "Acme Ltd")
+ page := b.get("/").Body
+ if !strings.Contains(page, `<div class="crumb"><a class="wordmark" href="`+issuerOrigin+`/">base</a>`) {
+ t.Errorf("no link to Base's Home:\n%s", page)
+ }
+ if !strings.Contains(page, `<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out of Scratchpad</button></form>`) {
+ t.Errorf("no sign-out control:\n%s", page)
+ }
+ if r := b.do(http.MethodPost, consumer.SignOutPath, url.Values{}, appOrigin); r.Code != http.StatusSeeOther || r.Header.Get("Location") != consumer.SignedOutPath {
+ t.Fatalf("sign out: %d %q", r.Code, r.Header.Get("Location"))
+ }
+ if r := b.get("/"); r.Code != http.StatusSeeOther || !strings.HasPrefix(r.Header.Get("Location"), consumer.StartPath) {
+ t.Fatalf("still signed in after signing out: %d", r.Code)
+ }
+}
diff --git a/internal/scratchpad/templates/notes.html b/internal/scratchpad/templates/notes.html
index 9bfea15..a858913 100644
--- a/internal/scratchpad/templates/notes.html
+++ b/internal/scratchpad/templates/notes.html
@@ -1,7 +1,7 @@
{{define "title"}}Scratchpad · {{.Base}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>Scratchpad</span></div>
+<div class="crumb"><a class="wordmark" href="{{.Home}}">base</a><span>Scratchpad</span></div>
<h2>Scratchpad</h2>
<p class="lead">Signed in as {{.Name}}, {{.Base}}</p>
{{if .Conflict}}<p role="status">Someone else saved this note while you were editing it. Your text is below and hasn't been saved. Save again to replace their version.</p>
@@ -14,5 +14,6 @@
{{.Note}}</textarea>
<button class="btn" type="submit">Save</button>
</form>
+<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out of Scratchpad</button></form>
</div>
</main>{{end}}
diff --git a/internal/web/templates/people.html b/internal/web/templates/people.html
index da36325..dda6c52 100644
--- a/internal/web/templates/people.html
+++ b/internal/web/templates/people.html
@@ -1,7 +1,7 @@
{{define "title"}}People · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>People</span></div>
+<div class="crumb"><a class="wordmark" href="/">base</a><span>People</span></div>
<h2>People</h2>
<p class="lead">Everyone here can sign in to every app on {{.Name}}'s Base. Each app decides what they can do in it.</p>
{{if .BadEmail}}<p role="status">That doesn't look like an email address.</p>
diff --git a/internal/web/templates/settings.html b/internal/web/templates/settings.html
index f81df5a..d240047 100644
--- a/internal/web/templates/settings.html
+++ b/internal/web/templates/settings.html
@@ -1,7 +1,7 @@
{{define "title"}}Settings · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>Settings</span></div>
+<div class="crumb"><a class="wordmark" href="/">base</a><span>Settings</span></div>
<h2>Settings</h2>
<ul class="people">
<li><div class="who">Base name<small>{{.Name}}</small></div></li>
@@ -10,7 +10,8 @@
</ul>
{{if .PasskeyAdded}}<p class="status" role="status" id="passkey-added">Passkey added. Next time, sign in with it.</p>
{{end}}<p class="status" id="passkey-msg" aria-live="polite"></p>
-<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out</button></form>
+<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out of Base</button></form>
+<p class="soon">This signs you out of Base only. Apps you've opened stay signed in until you sign out of each one.</p>
</div>
<script type="module" src="{{asset "static/passkey-add.js"}}"></script>
</main>{{end}}
diff --git a/internal/web/templates/store.html b/internal/web/templates/store.html
index 3e9227d..bf6c8e6 100644
--- a/internal/web/templates/store.html
+++ b/internal/web/templates/store.html
@@ -2,7 +2,7 @@
{{define "head"}}{{if .Installing}}<meta http-equiv="refresh" content="2">{{end}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>Store</span></div>
+<div class="crumb"><a class="wordmark" href="/">base</a><span>Store</span></div>
<h2>Store</h2>
<p class="lead">Apps that run on {{.Name}}'s Base. Install one and it's on Home for everyone at {{.Name}}.</p>
{{if .Busy}}<p role="status">This app is still installing. Try again in a moment.</p>
diff --git a/internal/web/templates/uninstall.html b/internal/web/templates/uninstall.html
index 1f04b54..0bb5f37 100644
--- a/internal/web/templates/uninstall.html
+++ b/internal/web/templates/uninstall.html
@@ -1,7 +1,7 @@
{{define "title"}}Uninstall {{.App.Name}} · {{.Name}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>Store</span></div>
+<div class="crumb"><a class="wordmark" href="/">base</a><span>Store</span></div>
<h2>Uninstall {{.App.Name}}?</h2>
<div class="confirm">
<p>Uninstall {{.App.Name}}? It's removed from Home for everyone at {{.Name}}. Its data is kept, and comes back if you install it again.</p>
diff --git a/internal/webtest/settings_test.go b/internal/webtest/settings_test.go
index 4810107..a58c7df 100644
--- a/internal/webtest/settings_test.go
+++ b/internal/webtest/settings_test.go
@@ -29,3 +29,27 @@ func TestSettingsSignOut(t *testing.T) {
t.Fatalf("still signed in: %d %q", r.Code, r.Location())
}
}
+
+// Finding 7 (R30): Base's sign-out says it is Base's alone.
+func TestSettingsSignOutSaysBaseOnly(t *testing.T) {
+ a := newApp(t)
+ a.signedInOwner()
+ body := a.get("/settings").Body
+ for _, want := range []string{">Sign out of Base</button>", "This signs you out of Base only. Apps you've opened stay signed in until you sign out of each one."} {
+ if !contains(body, want) {
+ t.Errorf("settings lacks %q:\n%s", want, body)
+ }
+ }
+}
+
+// Finding 8: every inner page's "base" wordmark is a link to Home.
+func TestInnerPagesLinkHome(t *testing.T) {
+ a := newApp(t)
+ a.signedInOwner()
+ a.setInstall("scratchpad", "installed", "")
+ for _, p := range []string{"/people", "/store", "/settings", "/store/scratchpad/uninstall"} {
+ if body := a.get(p).Body; !strings.Contains(body, `<div class="crumb"><a class="wordmark" href="/">base</a>`) {
+ t.Errorf("%s has no link to Home:\n%s", p, body)
+ }
+ }
+}
diff --git a/internal/welcome/templates/welcome.html b/internal/welcome/templates/welcome.html
index 2892f45..4fa06f2 100644
--- a/internal/welcome/templates/welcome.html
+++ b/internal/welcome/templates/welcome.html
@@ -1,9 +1,10 @@
{{define "title"}}Welcome · {{.Base}}{{end}}
{{define "main"}}<main class="inner">
<div class="sheet glass">
-<div class="crumb"><div class="wordmark">base</div><span>Welcome</span></div>
+<div class="crumb"><a class="wordmark" href="{{.Home}}">base</a><span>Welcome</span></div>
<h2>Welcome, {{.Name}}</h2>
<p class="lead">This is {{.Base}} on Base. Your team's apps are on Home.</p>
-<a class="btn" href="{{.Home}}">Back to Home</a>
+<div class="actions"><a class="btn" href="{{.Home}}">Back to Home</a>
+<form method="post" action="/auth/signout"><button class="btn ghost" type="submit">Sign out of Welcome</button></form></div>
</div>
</main>{{end}}