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
This commit is contained in:
2026-11-23 17:46:58 +01:00
parent dd2dd53d7e
commit 1f63a7063c
5 changed files with 688 additions and 9 deletions
@@ -0,0 +1,377 @@
---
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.
+175 -7
View File
@@ -9,9 +9,11 @@ status: open
# Event-driven refactor of the repository
**Decided by the user on 2026-11-23: this repository is to be refactored as a whole, following an
event-driven pattern.** The user will provide the instructions and a guidelines document.
**Nothing is designed or built until that document arrives.** This page holds what is decided,
what is not, and what the decisions touch in the code as it stands.
event-driven pattern.** The user's guidelines document arrived the same day:
`EDA/wiki/guideline-joining-the-platform.md` (the platform wiki, not this vault). The user's
instructions on what to do with it have not been given. **Nothing is designed or built.** This
page holds what is decided, what is not, what the decisions touch in the code as it stands, and
how the guideline reads against this repository.
How it came up: the discussion on bringing the ideas of the [[zone-anpr-poc]] into the product
([[passage-confirmation]]), and the H.264 decoding test of the same day.
@@ -41,10 +43,11 @@ How it came up: the discussion on bringing the ideas of the [[zone-anpr-poc]] in
## Not decided
- **Which bus, and how it relates to the platform.** Suggested by the assistant and not
confirmed by the user: the buffered NATS leaf on the booth PC that the platform wiki describes
for syncing the ledger (`EDA/wiki/queries/q-parking-core-service-on-the-platform.md`, deferred
by the user on 2026-10-20) could also be this local bus.
- **Whether the parking system joins the platform as a leaf under the guideline.** The guideline
names the bus for any service that joins: NATS JetStream, on a site through the leaf stack of
the nats repo. It also lists "Parking as the first leaf product" under its own "Not decided"
(`EDA/wiki/queries/q-parking-core-service-on-the-platform.md`, deferred by the user on
2026-10-20). See "The guideline against this repository" below.
- The events: their names, their contents, who publishes and who consumes.
- How the booth screen gets the live picture, and how the vision side gets the camera logins.
Both were left to this refactor.
@@ -93,6 +96,171 @@ over").
6. **The repository's `CLAUDE.md`** still describes the server as the home of the device
drivers. Left as it is until the guidelines arrive.
## Scope, and the language (user, 2026-11-23)
Stated by the user after reading the guideline's collisions:
- **A multi-tenant core server handles all future parks.** The core only shows records, and
only those a booth has synced to it.
- **The parks already running (park-buzi, park-2) stay out of this refactor for now.** Later it
must be possible to migrate them into the new architecture.
- **The park is offline-first.** The leaf lives with no internet connection and without the core
infrastructure.
- **The guideline binds the leaf only for the structure of users and permissions.** That was
said while Rust was on the table; with TypeScript and Docker chosen, the guideline's
technology table is the nearest standard for `apps/booth` and `apps/core`.
**Where it is built (user, 2026-11-23):** in this repository, on its own branch `eda_dev`, in
parallel to the existing code. New directories stand beside the
existing ones, named for what they are: **`apps/booth`** (the site) and **`apps/core`** (the
multi-tenant core), agreed by the user in place of the first examples `apps/web_new` and
`apps/server_new`. The existing apps keep serving the running parks from `dev` → `stage` →
`main`.
- `eda_dev` was cut from `stage` on 2026-11-23, which was 80 commits ahead of `dev` and had
nothing behind it.
- The build and deploy workflows run on `dev`, `stage` and `main` only, and the Komodo stacks
are pinned to `stage` tags, so a push of `eda_dev` builds and deploys nothing
(`.gitea/workflows/`, `komodo/resources.toml`).
- `pnpm-workspace.yaml` takes every directory under `apps/` and `packages/`, so a new directory
with a `package.json` joins the workspace and the Turbo tasks on that branch.
**The language is TypeScript, delivered with Docker (decided, user, 2026-11-23): "I abandoned
the idea of Rust."** Earlier the same day the user had asked whether to remove Docker from the
leaf and rebuild every service in Rust, because the booth relies on a lot of RAM and SSD
today. The measurements below were taken for that question and stay as a record.
**Measured on park-lab the same day** (7.2 GB RAM, 5.0 GB available; 231 GB disk, 23 GB used):
| | Memory | Disk |
|---|---|---|
| Server (Node) | 87 MB | image 378 MB |
| Vision service (Python) | 425 MB | image 1.95 GB |
| Proxy (Caddy) | 11 MB | image 92 MB |
| Docker itself (dockerd, containerd, shims, proxy) | about 230 MB | build cache 4.5 GB |
| Komodo Periphery | 23 MB | |
| The zone PoC, for comparison | 401 MB | image 3.37 GB |
- The memory sits in the vision side (model runtime and frames), not in the Node server.
- The disk incident at park-2 was backups and snapshots, not images ([[park-2-disk-growth]]).
- Size of what a rewrite covers: about 26,000 lines of TypeScript behind the API (server,
device drivers, database, shared) with about 11,000 lines of tests; 19,000 lines of web app
that could stay if the API is kept; about 1,000 lines of Python in the vision service.
**What staying with Docker keeps:** deployment and remote control on Komodo, which drives
compose stacks ([[fleet-deployment-komodo]], [[container-deployment]]), and the platform's leaf,
which is delivered as a compose stack (`nats/compose.leaf.yaml`).
## Users and permissions, the first piece (2026-11-23)
The user asked where to start; users and permissions is the candidate, as a model on paper
before any code. The old permissions are, in the user's words, sloppy work. What the code shows:
verbs standing in for scope (`shift:cash`, `drawer:review`, `subscription:plan`,
`carwash:cash`), a catch-all (`site:update`), names that hide what they grant (`barrier:create`,
`session:create`), one role per user with extra bindings outside the grid, module permissions in
the one shared list (`packages/shared/src/index.ts`), a login token with no expiry
(`apps/server/src/auth.ts`).
**Decided by the user (2026-11-23); the detail is on [[booth-users-and-permissions]]:**
- **Everything about identity is in the platform, and the booth is in constant sync with it,
both ways.** Users, members, policies and the catalogue have their home in the platform's
auth service; the booth holds a copy, password hashes included. With no link the booth goes
on working and catches up later.
- **Login at the booth is local,** against the copy, with a session cookie for the booth's own
domain or IP address.
- **Users and policies can be changed at the booth or on the platform, at any time, by whoever
holds the right.** The same holds for creating a park's operators.
- **Login is by username; email is optional.** The platform is to take this (a change in the
platform, not made from here).
- **Three kinds of people, all platform users:** our staff (tenants, access, subscriptions; no
access to the services), the tenant admin (the owner; holds everything on the tenant's parks;
can have many parks), the park's people (policies, and the parks assigned to them).
- **A park is one site with one booth host;** no level between them until a park has two hosts.
- **The booth is the only writer of its ledger.** The platform syncs, reads and monitors, and a
booth is recovered from it. Entries are signed with a key pair on P-256.
- **Two product keys:** `auth` for users, members and policies (the platform's catalogue,
always on); `parking` for everything else, registered on the platform, in the form
`parking.payment:take`.
- **Scope in the permission string** (`parking.shift:read@assigned`, `@all`), **a password of
at least 12 characters, no lock for wrong passwords,** a first password given as a one-time
code valid 24 hours.
- **Validation and the car wash are not part of the booth.** They will connect to each other
and to parking as business to business. Postponed: the user asked not to be asked about them
again; separate services are built if need be (car wash, hotels, cafés).
Earlier the same day the accounts of a park were placed on the booth only ("three rings"), with
signed commands from the core. That was replaced by the first point above; the model page
lists each earlier ruling and what became of it, what the platform needs for this, and the
technical points left to the design of the sync.
The platform's structure this is mapped onto: `nats/wiki/decisions/adr-0002-auth-and-tenancy-model.md`,
`auth-service/wiki/concepts/policies.md`, `auth-service/wiki/concepts/data-model.md`,
`EDA/wiki/decisions/xadr-0002-permission-catalogue-registration.md` (paths from the `EDA/` root).
## The guideline against this repository (2026-11-23)
Source: `EDA/wiki/guideline-joining-the-platform.md`. A reading, with nothing designed from it.
**Whose rule is what, as the guideline itself says:**
- **Rule 1, one concern, one service,** is the user's. A system that arrives with its own
login, its own administration screens and its own cloud back end in one deployable is split
first.
- **Rule 2, the site carries only what must be on the site,** is the platform architect's
reading, not yet confirmed by the user. So is the rule that unproven leaf mechanics are proven
on the lab box first.
- **Its "Not decided" list** holds three things this refactor runs into: parking as the first
leaf product; a local operator login while the link is down; a standard for a service with no
HTTP API, which is what a vision service that talks to cameras would be.
**Rule 1, row by row, against what this repository does today:**
| Concern | Owner on the platform | In this repository today |
|---|---|---|
| Users, login, sessions | auth-service | its own: tables `users`, `roles`, `sessions` (`packages/db/src/schema.ts`), `apps/server/src/routes/auth.ts`, `@fastify/jwt` ([[local-jwt-auth]]) |
| Which tenant may use which product | auth-service | its own flags: `MODULES_ENTITLED` and the site's activation (`apps/server/src/modules.ts`, [[venue-modules]]) |
| Permissions | declared by the service, evaluated by auth-service | its own roles and permissions (`apps/server/src/routes/roles.ts`, `users.ts`) |
| Login page, administration | admin-ui | in its own SPA, with Setup (`apps/server/src/routes/setup.ts`) |
| Product screens | a static product app | the SPA is served by the server (`@fastify/static`) and wrapped by the desktop shell ([[desktop-shell-tauri]]) |
| Data from another service | the backbone, never a REST call at run time | the server calls the vision service over HTTP (`apps/server/src/vision-client.ts`); the review outbox posts over HTTP (`apps/server/src/modules/carwash/review-outbox.ts`) |
| Live updates to browsers | websocket-service | its own socket, `/api/ws` (`apps/server/src/routes/ws.ts`, [[booth-console]]) |
| Device protocols | adapters that publish canonical events | drivers inside the server process (`packages/devices/`), and device pushes received by the server (`apps/server/src/routes/hikvision-alarm.ts`, `qr-reader.ts`) |
| Streams, buckets, consumers | the nats repo, as config | none |
| Shared schemas and guards | eda-libs (`@eda/*`) | `packages/shared/` |
| Build and deploy | Gitea CI builds, Komodo deploys | already so (`komodo/resources.toml`, [[fleet-deployment-komodo]], [[container-deployment]]) |
**Technologies the guideline requires, against the repository's own guide (`CLAUDE.md`):**
| Guideline | This repository | |
|---|---|---|
| NestJS on Fastify | plain Fastify | differs |
| Its own PostgreSQL through Drizzle | SQLite through Drizzle; PostgreSQL a deferred sync target | differs |
| A static app on nginx | the SPA served by Fastify | differs |
| No user table and no login route in the service | local login, "no external identity provider" ([[offline-first]]) | collides |
| No socket of its own to browsers | `/api/ws` to the booth screen | collides |
| NATS JetStream between services | direct calls; a broker was skipped in 2026-06 ([[dingtian-vs-mqtt]]) | collides for the path that opens the barrier |
| A wiki in the repository, Komodo, Gitea | present | matches |
| Agents push `dev` only; branches `dev` → `stage` → `main` | the three branches exist; work here has gone to `stage` | differs |
None of these is resolved here. The repository's guide binds until the user changes it.
**What the guideline does not answer:**
- Video. It has no word on streams, pictures or a live picture; how the booth screen gets its
picture stays open.
- Device logins. It covers a service's own NATS key, not the logins of cameras, relays or
readers.
- A booth screen that has to work while the link is down. It places screens and browser push on
the hub side and lists the offline operator login as not decided. [[offline-first]] needs the
booth to work with no link at all.
- The signed ledger and its single signer. Not a subject of the guideline; the platform wiki's
parking query treats it.
**Steps that are not in this repository.** The guideline's first steps are an accepted
cross-service decision, a row in the platform's service registry, backbone access and a key.
They are made in the platform wiki and the nats repository.
## What stays whatever the shape
From the repository's guide, and not put in question by the user: [[offline-first]], the signed
+4 -1
View File
@@ -2,11 +2,14 @@
type: entity
tags: [parking, stack, auth, offline-first]
sources: [parking-system-architecture]
updated: 2026-06-15
updated: 2026-11-23
---
# Local JWT Auth
> **2026-11-23:** the new booth of the [[event-driven-refactor]] gets a different scheme, modelled on
> [[booth-users-and-permissions]]. This page describes what runs today and at the running parks.
Authentication and authorization, kept **fully local** — a direct consequence of
[[offline-first]] (an air-gapped park cannot reach an external identity provider; see
[[logto-zitadel-oidc]] for the rejected alternative). (See [[parking-system-architecture]] §2.)
+2 -1
View File
@@ -7,7 +7,7 @@ updated: 2026-11-23
# Index
Content catalog for the wiki. Start at [[overview]]. Maintained on every ingest.
Counts: 7 sources · 28 entities · 68 concepts · 23 decision records.
Counts: 7 sources · 28 entities · 68 concepts · 24 decision records.
## Overview & navigation
- [[overview]] — the top-level synthesis and entry point.
@@ -153,6 +153,7 @@ Counts: 7 sources · 28 entities · 68 concepts · 23 decision records.
- [[forgiven-exit]] — decision + as-built (2026-10-08): owner opens the EXIT barrier with no payment — a signed zero-amount payment carrying the forgone fee as its own Z-report line (never in cash/card), exit only, admin permission + open shift, reason optional, prints nothing.
- [[vision-service-packaging]] — the vision service lives in this monorepo (apps/vision/), separate process, wired into Turbo via a package.json shim; uv-managed Python.
- [[camera-live-view]] — BUILT 2026-11-17: booth camera tiles from the device footer — latest snapshot at rest, live video while that camera sees a vehicle; sub-stream MJPEG over RTSP, reassembled in-process (RFC 2435), one shared session per camera, latest-frame WS delivery; open tiles a user preference; large view with Live/Snapshot; 1280×720, no fps cap. Measured: ~0.1 s delay on the LAN, no extra ANPR 503s.
- [[booth-users-and-permissions]] — 🟡 OPEN (2026-11-23): users and permissions for the new booth — identity has its home in the platform and the booth is in constant two-way sync, local login from the copy, two product keys (`auth`, `parking`), 37 proposed keys, all 44 of today's permissions mapped, two jobs, the rules, signing with a key pair, what the platform needs, what is left to the sync design. Nothing built.
- [[event-driven-refactor]] — 🟡 OPEN (user, 2026-11-23): the whole repository is to be refactored along an event-driven pattern — a bus between vision, server and booth screen, no video/image work in the server, the camera as one signal among several. Waits for the user's guidelines; lists what it touches in today's code and where it meets what is built.
- [[event-streams-split]] — split the signed business ledger (ledger_events) from unsigned device telemetry (device_events).
- [[desktop-shell-tauri]] — ✅ Tauri v2 chosen over Electron for the desktop kiosk shell; thin wrapper, server keeps all logic. Best case Ubuntu 26.04 LTS (resolves WebKitGTK); worst case Windows+WSL → kiosk browser, no native shell. Auto-updater mirrors signed releases to public `mca/public_releases` (source repo is private — field appliances have no Gitea creds).
+130
View File
@@ -4069,3 +4069,133 @@ the camera gate on the entry button stays; a camera that is healthy but blinded
matter of the business, not the system's concern. The two points are marked settled on
[[event-driven-refactor]]; the notes on [[entry-double-press]], [[operator-issued-entry]] and
[[entry-presence-bypass]] say so.
## [2026-11-23] query | Event-driven refactor — the guideline read against the repository
The user handed over `EDA/wiki/guideline-joining-the-platform.md`. Read against this repository
and recorded on [[event-driven-refactor]]: its Rule 1 row by row against what the code does
today, the required technologies against the repository's guide, what the guideline does not
answer (video, device logins, a booth screen with no link, the ledger's signer), and which of its
steps lie outside this repository. Whether parking joins the platform as a leaf is on the
guideline's own "Not decided" list. Nothing designed, nothing built.
## [2026-11-23] query | Event-driven refactor — scope, and the Rust question
The user: a multi-tenant core for all future parks that only shows synced records; park-buzi and
park-2 stay out for now and migrate later; the park is offline-first and the leaf lives without
the core; the guideline binds only the structure of users and permissions. Asked, not decided:
drop Docker on the leaf and rebuild every service in Rust, starting with users and permissions.
Measured park-lab's memory and disk per service and sized the code; on [[event-driven-refactor]].
## [2026-11-23] query | Event-driven refactor — built on branch `eda_dev`, parallel to the existing code
The user: whichever language, the work goes to another branch (`eda_dev`) and is built beside the
existing code in new directories (examples: `apps/web_new`, `apps/server_new`). Branch created
from `stage`; nothing pushed. Noted on [[event-driven-refactor]] with what the branch does and
does not trigger.
## [2026-11-23] query | Event-driven refactor — users and permissions as the first piece
Names agreed: `apps/booth` and `apps/core`. The user: start with users and permissions (the old
ones are sloppy); username login with email optional; the booth is the only signer, the core
syncs, reads and monitors, and a booth is recovered from the core; the platform admin manages
tenants and subscriptions only; a tenant admin can have many parks. The levels are not settled;
the assistant's three-ring proposal is recorded as a proposal on [[event-driven-refactor]].
## [2026-11-23] query | Users and permissions for the new booth — the model
The user confirmed the three rings and asked for the model page. New page
[[booth-users-and-permissions]]: what is kept from today's scheme (login until logout, the
never-locked-out admin, no grant beyond your own, jobs applied by an admin, per-desk money
guards, the filtered feed), what the code shows as wrong, the model (users, members, policies
with scope, several per member, opaque sessions), a proposed catalogue of 45 keys in four
products, all 44 of today's permissions mapped (checked by script against `PERMISSIONS`), the
four jobs re-expressed, the rules, what reaches the core (proposed), where the booth differs
from the platform, ten open points. Rings moved to "decided" on [[event-driven-refactor]].
Nothing built, nothing committed.
## [2026-11-23] query | Booth users and permissions — validation and car wash out; changes from the core
The user, after reading [[booth-users-and-permissions]]: validation and the car wash are to be
separate services with their own permission sets, so their keys leave the booth's catalogue,
and the jobs Merchant and Wash operator are removed. The catalogue is now 35 keys in two
products (`site`, `parking`); the 44 permissions of today are still each mapped, those of the
two services as "leaves" (checked by script). The second reversal of 2026-09-05 (a copy of
shift and drawer keys per module) no longer arises. The user also asked whether one
cryptography can sign the ledger whatever the origin, with the case of a tenant admin creating
a booth admin from a phone while the park may be offline. Recorded as raised and proposed, not
decided: a key pair per origin, a signed command from the core, the booth as the only writer of
its chain, and four points open within it (whose key signs for the person, which changes may
start at the core, the first password, the algorithm). Noted on [[event-driven-refactor]].
## [2026-11-23] query | Booth users and permissions — changes from the core decided
The user ruled on the four points of "Changes that start at the core" on
[[booth-users-and-permissions]]: the core's key signs for the tenant admin; only users and
grants may be changed from the core; the first password is a one-time code; P-256 for ledger
entries on both sides. Section moved from proposed to decided. It follows that user changes
made at the booth are ledger entries too. Still open: the code's validity, a command whose
target changed while offline, the no-grant-beyond-your-own rule for a tenant admin, lockout
with the link down. Hub page [[event-driven-refactor]] updated.
## [2026-11-23] query | Booth users and permissions — three more rulings on commands from the core
The user: a one-time code is valid 24 hours from issue; no command is issued while the booth is
offline (disabled buttons and a visible note on the core); "no grant beyond your own" holds for
the tenant admin. Recorded on [[booth-users-and-permissions]] as rulings 5–7; the walk-through
there no longer has a command waiting for an offline park. Open: what "your own" means across
the two catalogues, a command sent as the link drops, how the core knows a booth is online. The
lockout point was not understood as written and is to be explained again.
## [2026-11-23] query | Booth users and permissions — no lockout, tenant admin as owner
The user: no account is locked for wrong passwords at a booth; a forgotten admin password with
the link down is solved by bringing the link up (a personal phone's hotspot) or waiting, then a
reset from the core; a tenant admin counts as holding everything on their parks ("the tenant
admin is the owner"). Recorded on [[booth-users-and-permissions]] as rule 12 and rulings 8–9.
A growing wait between wrong tries is proposed with the no-lock rule and not confirmed.
## [2026-11-23] query | Booth users and permissions — scoped strings, 12 characters, B2B postponed
The user: scope in the permission string is taken (it reverses the 2026-09-05 rejection, with
the scope now meaning ownership); a password has at least 12 characters; validation and the
car wash will connect to each other and to parking as business to business, postponed, not to
be raised again; separate services are built if need be (car wash, hotels, cafés). Recorded on
[[booth-users-and-permissions]] and [[event-driven-refactor]]. The product key `site` was not
understood as asked and is to be explained again.
## [2026-11-23] query | Booth users and permissions — one product key, `parking`
Asked whether to keep a second product key `site` for what is not parking as a business, the
user answered "parking.payment:take. This format". Read as: one product key, `parking`, for
every key of the booth. The 17 `site.*` keys were renamed to `parking.*` on
[[booth-users-and-permissions]] (35 keys, one product, no clash; mapping and jobs re-checked by
script). Consequence noted under entitlements: switching `parking` off would also stop user
management, backup and the ledger view unless those keys are excepted.
## [2026-11-23] query | Booth users and permissions — users and grants under `auth`
The user showed the platform's admin console (tenant policies `auth-admin`, `gps-admin`) to
make clear what a product key is, and ruled: the booth's user and policy keys move to `auth`,
by the separation of concerns already on [[event-driven-refactor]] (Rule 1). The earlier
reading "one product key, `parking`" was wrong and is replaced. On
[[booth-users-and-permissions]]: `auth.user:read|manage`, `auth.member:read|manage`,
`auth.policy:read|manage` with the platform's names (`auth.user:manage` is the booth's own, the
platform leaves it out on purpose); 31 keys stay under `parking`; 37 in all, mapping and jobs
re-checked by script. `auth` is always on, as on the platform.
## [2026-11-23] query | Booth users and permissions — home on the platform
The user, on the booth-only key `auth.user:manage`: "Why we leave the auth out of the platform?
Everything should be in the platform. This, as leaf service will sync everything with the
platform." Recorded as a change of direction at the top of [[booth-users-and-permissions]] and
on [[event-driven-refactor]]: identity has its home in the platform's auth service, the booth
holds a synced copy. The page's sections that place accounts on the booth only are marked as
not yet reworked. Four hinge points proposed: no user or policy change at the booth; password
hashes reach the booth; who creates a park's operators on the platform; what the rulings on
commands from the core become.
## [2026-11-23] query | Booth users and permissions — reworked for constant sync
The user: login at the booth is local, with a cookie for the local domain or IP; users and
policies can be changed at the booth whenever, by whoever holds the right, link or not;
everything is in constant sync, which is the purpose of the leaf; a park's operators are
created by whoever holds the right; and no more questions on changes from the core.
[[booth-users-and-permissions]] rebuilt: "Where identity lives" and "The people" replace the
three rings and the commands from the core; a table lists each earlier ruling of the day as
replaced or standing; "What the platform needs for this" (username login, `auth.user:manage`,
a leaf holding identity and hashes, changes taken in from a leaf, the `parking` catalogue);
ten technical points are left to the design of the sync with a default each, not to be put to
the user again. Catalogue, mapping, jobs and rules unchanged (37 keys, checked by script).
[[event-driven-refactor]] and the index updated.
## [2026-11-23] query | Event-driven refactor — TypeScript with Docker; Rust abandoned
The user: "TypeScript with Docker I guess. I abandoned the idea of Rust." Recorded on
[[event-driven-refactor]]; the park-lab measurements taken for the Rust question stay as a
record. Komodo and the compose-delivered leaf are kept.