Phase 10, part 5: access enforced on every page, form and fragment
One table maps every address to an area (a module, Settings, anything signed in, or public); each route is checked against it, and the app won't start with a route missing from it. Changing needs edit on the module. For members who may only view, forms that would change something are shown disabled and htmx buttons hidden. The menu, the Overview, Search and the SEO emails follow each person's modules; Settings is for admins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2263,6 +2263,36 @@ starts** (multi-tenant still doesn't).
|
||||
is on Your account rather than the invitation page, to keep joining to
|
||||
one plain form.
|
||||
|
||||
**Part 5 built 2026-11-25** on `phase10`.
|
||||
- `routeAreas` (internal/web/access.go) is the one table: address
|
||||
prefixes to areas: a module (content, prospects, seo, sites, metrics,
|
||||
market), `admin` (Settings, `/auth`), `signed-in` (the Overview, Search,
|
||||
Your account, photos) or `public`. Every route is registered through a
|
||||
wrapper that looks its area up and checks it on each request; a route
|
||||
missing from the table stops `Handler()`, so the app won't start and
|
||||
every web test fails. `TestEveryRouteHasAnArea` also checks a made-up one.
|
||||
- A GET reads; anything else changes, which needs *edit* on the module.
|
||||
Outside someone's access: the 403 page, or a plain 403 for htmx and
|
||||
forms. Not signed in: to `/signin`.
|
||||
- For members, pages are rewritten as they're rendered: each form that
|
||||
posts to an area they can't change is wrapped in a disabled
|
||||
`<fieldset class="readonly">` (its text stays readable, its buttons are
|
||||
hidden) and gets no CSRF token; htmx buttons that would change something
|
||||
are hidden. The same table decides, so the page and the server agree.
|
||||
- The sidebar, the Overview's cards, the Market link and Search's groups
|
||||
show only the viewer's areas; the setup steps and import notes only to
|
||||
admins. Settings and its tabs are for admins; others see Your account
|
||||
(`/settings` takes them there).
|
||||
- The SEO morning check and Monday report, on the server edition, go to
|
||||
each active person with SEO who chose them (Your account), through the
|
||||
app's mail, with how to stop; the SEO settings' own two boxes are for the
|
||||
local edition.
|
||||
- Checked: an owner invites an admin and an SEO-only member; the member
|
||||
signs in and sees only SEO; 47 pages across every area answer 200 or 403
|
||||
as they should, for the member, the admin and the owner; changes and
|
||||
htmx fragments outside SEO answer 403. (The log part of *done when*
|
||||
comes with part 8.)
|
||||
|
||||
1. **Users and sessions.**
|
||||
- Tables:
|
||||
- `users`: email, name, kind (person or agent), status (invited,
|
||||
|
||||
Reference in New Issue
Block a user