Files
parking_solution/wiki/decisions/booth-users-and-permissions.md
T
julian 1f63a7063c wiki: users and permissions for the new booth, TypeScript with Docker
New decision page booth-users-and-permissions: identity has its home in
the platform and the booth is in constant two-way sync, local login from
the copy, product keys auth and parking, 37 proposed keys with all 44 of
today's permissions mapped, two jobs, the rules, key-pair signing, what
the platform needs, and what is left to the sync design.

Hub page event-driven-refactor: the decisions of 2026-11-23 on users and
permissions, validation and car wash out of the booth (postponed), and
the language (TypeScript with Docker; Rust abandoned).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RZgP5oZdzvo92Eouc9eRv5
2026-11-23 17:46:58 +01:00

378 lines
24 KiB
Markdown

---
type: decision
tags: [parking, decisions, auth, permissions, users, booth, core, multi-tenant, event-driven, sync]
sources: []
updated: 2026-11-23
status: open
---
# Users and permissions for the new booth — the model
The first piece of the [[event-driven-refactor]]: who may do what at a booth, in the structure
of the platform. **A model on paper. Nothing is built, and no language is assumed.**
Each part says whether it is **decided** by the user or **kept** from what runs today. The
single permission keys are proposed. What is left to the design of the sync is listed at the
end and is not put to the user again.
The platform's structure this follows (paths from the `EDA/` root):
`nats/wiki/decisions/adr-0002-auth-and-tenancy-model.md`,
`auth-service/wiki/concepts/data-model.md`, `auth-service/wiki/concepts/policies.md`,
`auth-service/wiki/concepts/login-security.md`,
`EDA/wiki/decisions/xadr-0002-permission-catalogue-registration.md`.
## Where identity lives (decided, user, 2026-11-23)
The user: "Everything should be in the platform. This, as leaf service, will sync everything
with the platform." And: "Everything is in constant sync. That is the purpose of the leaf
service. If there is no internet, who cares, the booth work will still flow."
- **The home of users, members, policies and the catalogue is the platform's auth service.**
Nothing about identity is defined at the booth only.
- **The booth holds a copy and is in constant sync with the platform, both ways.** That
includes password hashes. With no link the booth goes on working from its copy, and the two
sides catch up when the link returns.
- **Login at the booth is local.** It is checked against the booth's copy and needs no
connection to the platform. The session cookie is issued for the booth's own domain or IP
address. A session at the booth is not a session on the platform, or the reverse.
- **Users and policies can be changed at the booth or on the platform, at any time, by whoever
holds the right,** with a link or without.
- **A park's operators are created by whoever holds the right to create users,** at the booth
or on the platform.
## The people (decided, user, 2026-11-23)
Three kinds of people, all users of the platform:
| Who | What marks them | What they can do |
|---|---|---|
| Our staff | the platform admin flag | create tenants, set their access and subscriptions. **No access to the services** |
| The tenant admin | the tenant admin flag | the owner: counts as holding everything on the tenant's parks |
| The park's people | policies, and the parks assigned to them | what their policies allow, on those parks |
- **Login is by username; email is optional.** The platform is to take this.
- **A tenant admin can have many parks.** Scope `all` on the platform means every park of the
tenant; `assigned` means the parks assigned to the person.
- **A park is one site with one booth host.** No level is added between them until a park has
two hosts.
**Validation and the car wash are out of the booth (decided, user, 2026-11-23).** They are to
be separate services, each with its own set of permissions. The booth's catalogue holds no key
of theirs, and the jobs Merchant and Wash operator are removed. They will connect to each other
and to parking as business to business. **Postponed by the user, who asked not to be asked
about them again:** separate services are built if need be, for a car wash, hotels, cafés and
the like. Nothing about them is designed or raised here until the user brings it up.
## What runs today, and what of it is kept
Today's scheme is on [[local-jwt-auth]] and [[venue-modules]] ("Permissions matrix"). It grew by
additions, and the user calls the result sloppy. Parts of it were deliberate decisions and are
kept.
**Kept:**
- **A login lasts until logout** (decided 2026-06-15): a relief who arrives late, or a forced
double shift, must not be logged out mid-duty. A [[shift]] is the accountability boundary, not
the login.
- **Guards check a permission, never a role name.**
- **One admin that can never be locked out:** it always holds everything, and the last one
cannot be removed or demoted.
- **No grant beyond your own:** a user can give, edit or reset only what lies within their own
permissions.
- **Jobs are code, grants are data, and a software update never widens a grant by itself**
(user, 2026-09-06): a job that grew in a release is re-applied by an admin's click.
- **Each desk's money is guarded by that desk's own permissions** (2026-09-05). The booth till
is guarded by parking's keys only; another service's till is that service's matter.
- **The live feed is filtered by permission,** and is not the reports screen (user, 2026-09-05).
- **Grant edits are signed** on the ledger.
- Soft delete of users and grants ([[soft-delete]]); one generic "invalid credentials" answer; a
user changes their own password only by proving the current one; the module gate before the
permission ([[venue-modules]]); money routes need an open shift.
**Scope in the permission string (decided, user, 2026-11-23).** On 2026-09-05 scoped strings
were rejected (`shift:create@carwash`, [[venue-modules]] "Permissions matrix"); the scope then
was the desk. The user now takes them with the scope meaning ownership (`all` or `assigned`),
in the form the platform's sessions and policies carry, `key@scope`. It is used on one key,
`parking.shift:read`.
The second rejection of that day, a copy of the shift and drawer resources per module, no
longer arises here: with the car wash out of the booth, the booth has one till.
**What the code shows as wrong** (`packages/shared/src/index.ts`, `apps/server/src/routes/`):
- **A verb standing in for ownership:** `shift:cash` means "sees every operator's shifts".
- **A catch-all:** `site:update` guards site settings, device setup, the discount programs and
the car-wash settings.
- **Names that hide what they grant:** `barrier:create` is the forgiven exit, `session:create`
the operator-issued ticket, `event:void` the ticket void.
- **Writes behind a read:** arming a card capture and printing a subscription card need only
`subscription:read`.
- **Keys that no guard checks:** `payment:read` and `validation:read` appear only in job presets.
- **Cross-cutting keys with no owner:** `event:read`, `drawer:review` and `shift:cash` cover every
desk at once.
- **One role per user,** with bindings outside the grid (a merchant's programs, the till guards).
- **Module permissions sit in the one shared list.**
- **User changes are not signed:** `apps/server/src/routes/users.ts` appends nothing to the
ledger; role edits do.
- **The login token cannot be revoked by itself:** the guard re-reads the user's role on every
request to make up for it.
## The model
| Platform | Booth today | New |
|---|---|---|
| User: global, email, argon2id | `users`: username, bcrypt, one `role_id` | **The platform's user,** with a username (email optional), copied to the booth with its argon2id hash and its disabled flag |
| Membership (user, tenant) with a `tenant_admin` shortcut | the built-in `admin` role | **The platform's member.** The admin flag is the shortcut: every permission of every enabled product at scope `all` |
| Policy: named, allow-only list of (permission, scope) | `roles` + `role_permissions` | **The platform's policy,** copied to the booth. A policy remembers the jobs it was composed from, as roles do today |
| Several policies per member; the union counts | one role per user | **Several policies per member;** the union counts, `all` beats `assigned` |
| Catalogue per product, `<product>.<resource>:<action>`, each key declaring its scopes | one list, `resource:action` | **The platform's `auth` catalogue, and a `parking` catalogue registered on the platform** as `gps` is |
| Session: opaque id, revocable, permissions computed in | a token with no expiry | **A local session:** an opaque id in the booth's database, its cookie for the booth's domain or IP. No expiry by time (kept). Ended by logout, a password change, disabling the user, or an admin |
| Entitlement per tenant and product | `MODULES_ENTITLED` and the site's activation | **The platform's entitlement,** copied to the booth |
- **Preferences** (language, theme, font size, open camera tiles) stay per user and are not part
of identity.
## The catalogue
**Two product keys, `auth` and `parking` (decided, user, 2026-11-23).** A product key is the
short name of a product a tenant is given on the platform, as `auth`, `fleet` and `gps` are
there. Users and grants are one concern and parking is another
([[event-driven-refactor]], Rule 1 of the guideline):
- **`auth`: users, members and policies.** The platform's catalogue
(`auth-service/src/permissions/auth-permissions.ts`), always on.
- **`parking`: everything else at the booth,** in the form `parking.payment:take`. That
includes the product's own settings, devices, backup, logs, recycle bin, reports and ledger,
as `gps.settings:*` and `gps.device:*` sit under `gps`.
**`auth.user:manage` is not in the platform's catalogue today.** The platform left it out on
purpose: only our staff create users there. With "whoever holds the right" it is needed on the
platform, where everything lives. That is a change in the platform, not made from this session.
The platform's `auth.tenant:read` and `auth.branding:manage` guard nothing at the booth.
**Scope `assigned`** is used on one booth key, `parking.shift:read`, where it means one's own
shifts. On the platform's side it means the parks assigned to a person.
The single keys below are proposed.
| Key | Scopes | Grants |
|---|---|---|
| `auth.user:read` | all | see the user accounts |
| `auth.user:manage` | all | create, change, disable, delete a user; reset a password |
| `auth.member:read` | all | see the members and the policies each holds |
| `auth.member:manage` | all | attach and detach policies; set the admin flag |
| `auth.policy:read` | all | see policies |
| `auth.policy:manage` | all | create, change, delete policies |
| `parking.settings:read` | all | see the site's settings and version |
| `parking.settings:manage` | all | change the site's settings, including the presence bypass |
| `parking.device:read` | all | device and printer status, the device part of the live feed, camera live tiles |
| `parking.device:manage` | all | Setup: discover, assign, test a relay, a printer, a camera |
| `parking.log:read` | all | the diagnostic log |
| `parking.recyclebin:read` | all | see deleted master data |
| `parking.recyclebin:restore` | all | restore it |
| `parking.recyclebin:purge` | all | remove it for good |
| `parking.backup:read` | all | backup status |
| `parking.backup:manage` | all | backup target and schedule |
| `parking.backup:run` | all | back up now |
| `parking.ledger:read` | all | every event of the signed ledger: the log, the live feed, the chain check |
| `parking.report:read` | all | the reports screen |
| `parking.session:read` | all | active sessions, lookup, quote, snapshots, occupancy |
| `parking.ticket:issue` | all | issue an entry ticket from the booth ([[operator-issued-entry]]) |
| `parking.ticket:void` | all | void a ticket (an appended event) |
| `parking.payment:take` | all | take a payment, print a voucher or receipt, open the exit, re-open the barrier |
| `parking.exit:forgive` | all | open the exit with no payment ([[forgiven-exit]]) |
| `parking.tariff:read` | all | read and simulate the tariff |
| `parking.tariff:manage` | all | drafts and new versions |
| `parking.subscription:read` | all | the subscription registry, a price quote |
| `parking.subscription:sell` | all | sell one: capture a card, print it |
| `parking.subscription:update` | all | change or revoke one |
| `parking.subscription:delete` | all | delete one |
| `parking.plan:manage` | all | compose the plan catalogue; move a sold subscription to another plan version |
| `parking.discount:read` | all | see the discount programs (a program is a parking discount; applying one is the validation service's act) |
| `parking.discount:manage` | all | compose the discount programs |
| `parking.shift:read` | assigned, all | `assigned` = own shifts and their cash movements; `all` = every operator's |
| `parking.shift:work` | all | open and close one's own booth shift |
| `parking.drawer:record` | all | record cash in and out on one's own shift |
| `parking.drawer:review` | all | authorize or deny a recorded movement |
Verbs other than read, create, update, delete and manage are used where the act is not a plain
edit (`take`, `issue`, `void`, `forgive`, `sell`, `work`, `record`, `review`, `run`, `restore`,
`purge`), as the platform does with `gps.device:release`.
## Every permission of today, mapped
All 44 entries of `PERMISSIONS`, each once. "Guards today" is what the code checks with it.
"Leaves" means the permission goes with the validation or the car-wash service and has no key
at the booth.
| Today | Guards today | New |
|---|---|---|
| `user:create` | create a user, with its role | `auth.user:manage`, `auth.member:manage` |
| `user:read` | list users, with their role | `auth.user:read`, `auth.member:read` |
| `user:update` | change a user and its role, reset a password | `auth.user:manage`, `auth.member:manage` |
| `user:delete` | delete a user | `auth.user:manage` |
| `role:create` | create a role | `auth.policy:manage` |
| `role:read` | list roles | `auth.policy:read` |
| `role:update` | change a role | `auth.policy:manage` |
| `role:delete` | delete a role | `auth.policy:manage` |
| `tariff:read` | read, simulate, list drafts | `parking.tariff:read` |
| `tariff:update` | drafts, new versions | `parking.tariff:manage` |
| `subscription:read` | the registry, plans and a quote; also arm and cancel a capture, print a card | `parking.subscription:read`; the capture and the print move to `parking.subscription:sell` |
| `subscription:create` | sell | `parking.subscription:sell` |
| `subscription:update` | change, revoke | `parking.subscription:update` |
| `subscription:delete` | delete | `parking.subscription:delete` |
| `subscription:plan` | compose, retire, reactivate, delete plans; move a sold subscription to another plan version | `parking.plan:manage` |
| `site:read` | site settings, version, occupancy, discount programs, car-wash settings | `parking.settings:read`; occupancy to `parking.session:read`; programs to `parking.discount:read`; the wash settings leave |
| `site:update` | site settings, presence bypass, all of Setup, discount programs, car-wash settings | `parking.settings:manage`, `parking.device:manage`, `parking.discount:manage`; the wash settings leave |
| `validation:create` | apply a discount, see and void one's own | leaves (validation) |
| `validation:read` | nothing; in the supervisor job only | leaves (validation); no guard uses it today |
| `device:read` | device and printer status, camera alarms, camera live tiles, the device part of the feed | `parking.device:read` |
| `shift:read` | read the booth till (through the till guard) | `parking.shift:read@assigned` |
| `shift:create` | open and close the booth shift (till guard) | `parking.shift:work` |
| `shift:cash` | see every operator's shifts, on every till | `parking.shift:read@all`; the wash till leaves |
| `drawer:create` | record booth cash in and out (till guard) | `parking.drawer:record` |
| `drawer:review` | review movements, on every till | `parking.drawer:review`; the wash till leaves |
| `payment:read` | nothing; in the two booth jobs only | dropped |
| `payment:create` | pay, voucher, receipt, exit, re-open | `parking.payment:take` |
| `session:read` | active sessions, lookup, quote, snapshots, the occupancy part of the feed | `parking.session:read` |
| `session:create` | issue an entry ticket | `parking.ticket:issue` |
| `event:read` | every event type in the log and the live feed, and the chain check; a role without it sees only the events of a module whose feed permission it holds | `parking.ledger:read` |
| `event:void` | void a ticket | `parking.ticket:void` |
| `report:read` | the reports screen | `parking.report:read` |
| `log:read` | the diagnostic log | `parking.log:read` |
| `recyclebin:read` | list | `parking.recyclebin:read` |
| `recyclebin:update` | restore | `parking.recyclebin:restore` |
| `recyclebin:delete` | purge | `parking.recyclebin:purge` |
| `backup:read` | status | `parking.backup:read` |
| `backup:update` | target, schedule, test | `parking.backup:manage` |
| `backup:create` | back up now | `parking.backup:run` |
| `carwash:read` | queue, lookup, wash settings, the wash till's state, the wash's events | leaves (car wash) |
| `carwash:create` | take in an order | leaves (car wash) |
| `carwash:update` | done, bay payment, void | leaves (car wash) |
| `carwash:cash` | open and close the wash shift, wash cash in and out (till guard) | leaves (car wash) |
| `barrier:create` | the forgiven exit | `parking.exit:forgive` |
Routes that need a login and no permission stay so: one's own profile, preferences and
password, and the list of tills one may read. `GET /api/setup/catalog` has no guard at all
today (driver schemas, no secrets).
## Jobs (kept, re-expressed)
A job is a bundle declared in code, offered as one click when composing a policy, and
remembered by the policy. The booth has two. Merchant and Wash operator are removed (user,
2026-11-23).
| Job | Contains |
|---|---|
| Booth operator | `parking.session:read`, `parking.ticket:issue`, `parking.payment:take`, `parking.ledger:read`, `parking.shift:read@assigned`, `parking.shift:work`, `parking.drawer:record`, `parking.device:read` |
| Booth supervisor | the operator's, with `parking.shift:read@all` in place of `@assigned`, plus `parking.ticket:void`, `parking.drawer:review`, `parking.report:read`, `parking.subscription:read`, `:sell`, `:update`, `parking.tariff:read` |
## Rules
Kept from today, in the new terms:
1. A guard names a permission; the admin flag passes every guard of an entitled product.
2. The last admin cannot be deleted or have the flag removed.
3. No grant beyond your own: for policies you write, policies you attach, and users you change.
4. The module gate comes first: a product that is not entitled or not activated answers "not
available", whatever the member holds.
5. A deleted user cannot log in, and their sessions end at once.
6. A policy or attachment change applies at once, with no new login.
7. A job is never applied by the software; a policy that is behind its job is shown as such.
New, as on the platform:
8. A user can be disabled without being deleted; a disabled user is treated as a deleted one in
rules 2 and 5.
9. A user cannot change the policies they hold themselves.
10. A password change ends the user's other sessions.
11. Unknown user, wrong password and disabled all answer the same.
11a. **A password has at least 12 characters** (decided, user, 2026-11-23), as on the platform;
the booth asks for 8 today.
12. **No account is ever locked for wrong passwords** (decided, user, 2026-11-23). At a booth
every login comes from one screen, so a lock would let anyone shut the admin out by typing
the admin's name. Proposed with it: each wrong try for a username makes the next one wait
longer (1 s, 2 s, 4 s, up to about 30 s), which slows guessing and locks nobody out.
## The ledger and signing (decided, user, 2026-11-23)
- **The booth is the only writer of its ledger.** The platform syncs, reads and monitors it.
- **A booth is recovered from the platform.** Users and policies come back by the sync, the
ledger from the platform's copy.
- **Entries are signed with a key pair, on the P-256 curve,** which the hardware signers
considered for the booth use ([[hardware-signer-options]], [[open-questions]] #6). Never a
secret shared by two sides, which is what today's signer is (`apps/server/src/signer.ts`):
whoever holds a copy can write any ledger.
- **The booth's private key never leaves the booth.** A rebuilt booth starts a new key; the
platform holds the public keys and records the change.
What follows for users and grants: a change that the booth applies is an entry in its ledger,
whether it was made at the booth or arrived by the sync. Today only role edits are signed
(`apps/server/src/routes/users.ts` appends nothing). A new user or a wider grant then leaves a
trace that no admin can remove.
## Earlier rulings of 2026-11-23 and what became of them
Made during the day, before "everything in the platform, in constant sync".
| Ruling | Now |
|---|---|
| Accounts of a park live on the booth only; no account is shared between the three rings | **Replaced.** All are platform users; the booth holds a copy |
| Password hashes stay on the booth | **Replaced.** Everything syncs |
| A change from the core is a command signed with the core's key, naming the person | **Replaced** by the sync |
| No command is issued while the booth is offline; the core disables the buttons | **Replaced.** A change made on the platform while a booth is offline reaches it when the link returns |
| The platform changes nothing at a booth but users and grants | **Stands.** The platform does not operate a park: no money, no barrier, no tariff |
| The first password is a one-time code, replaced at the first login, valid 24 hours from issue | **Stands** |
| "No grant beyond your own" holds for the tenant admin, who counts as holding everything on their parks | **Stands** |
| No account is locked for wrong passwords | **Stands** (rule 12) |
| A forgotten admin password with the link down: bring the link up through a phone's hotspot, or wait | **Stands,** and anyone at the booth who holds `auth.user:manage` can reset it there |
| A password has at least 12 characters | **Stands** (rule 11a) |
| P-256 for ledger entries | **Stands** |
## What the platform needs for this
For the platform wiki, which is not written from this session:
| Today on the platform | Needed |
|---|---|
| Users are identified by email | login by username, email optional (user) |
| Only platform staff create users; `auth.user:manage` is not in the catalogue | a tenant's person who holds the right creates users (user: "whoever has the right to do so") |
| A service keeps no users and no login | a leaf holds a copy of its park's users, members, policies and password hashes, and logs people in locally |
| Identity is changed in the auth service only | changes made at a leaf are taken in by the sync |
| No `parking` catalogue | the `parking` catalogue registered, so the policy editor offers its keys |
Where the booth still behaves differently, by the user's decisions:
| Platform | Booth | Decided |
|---|---|---|
| A session expires after 12 hours, renewed by use | no expiry by time | 2026-06-15 |
| An account is locked for 15 minutes after 5 wrong passwords | no lock | 2026-11-23 |
| Built-in policies are regenerated from the catalogue at every start | a software update never widens a grant by itself; jobs are applied by an admin's click | 2026-09-06 |
## Left to the design of the sync
Technical points, with the default that will be taken. They are not put to the user again
unless one of them turns out to change how a park works.
1. **The same user or policy changed in two places while the link was down.** Default: the
later change wins, and both stay in the history.
2. **The same username created in two places while the link was down.** Default: ids are
minted where the user is created and never clash; the later username is refused at sync
and shown to an admin.
3. **Which people are copied to which booth.** Default: the members assigned to that park, and
the tenant admins.
4. **Tenant id and site id** come from the platform when a booth is enrolled.
5. **Entitlements** are copied like the rest; a booth with no link keeps the last copy.
6. **Built-in policies.** The platform generates `parking-admin`, `-operator` and `-viewer` as
for every product. Default: they exist as on the platform, and the two jobs stay as presets
for custom policies.
7. **The wait between wrong password tries** (1 s, 2 s, 4 s, up to about 30 s), proposed with
rule 12.
8. **One key for a user.** Creating, changing and deleting a user are one key
(`auth.user:manage`); today they are three.
9. **The operator's live feed.** `parking.ledger:read` shows every event, as `event:read` does
today.
10. **The running parks** are out of the refactor for now. When they move, each of today's
roles becomes a policy by the mapping above, and passwords shorter than 12 characters
exist there.