feat(backend): link cards to users; charger-qualified gun restrictions; config-driven gun labels

- Allowlist entries take "user": <username> — sessions started with that
  card attribute to the person, and the owner sees their card's history
  even without gun-wide permissions (ownership looked up live)
- "guns": ["eu092025:2"] (fnmatch) replaces the charger-blind
  "connectors": [2] restriction — safe with multiple chargers
- New "chargers" config section provides per-charger/per-gun display
  names; the panel no longer hardcodes the Anfu gun labels
- Panel admin tab: owner dropdown + guns field on card entries
- Smoke test: 42 checks, incl. retroactive history visibility after
  linking a card and rejection of links to unknown users
This commit is contained in:
2026-07-11 20:03:36 +02:00
parent 3326c8d16c
commit 70c2fe1210
8 changed files with 85 additions and 39 deletions
+6 -1
View File
@@ -17,7 +17,12 @@ First card tapped on the real charger: idTag `1000000000000393` → Authorize
Flow for each new card: tap once in learn mode → harvest its idTag from `seen_tags.json` / `GET /api/allowlist` → add to `authorized` with a name (`kind: "card"`).
Since 2026-07-11 a card can be **restricted per gun**: an optional `"connectors": [2]` on its allowlist entry makes `decide()` reject it on any other connector. The check fires at `StartTransaction` (the only message that carries the connector); the preceding `Authorize` (tap) still says Accepted — harmless on this charger, because `AuthorizeRemoteTxRequests=false` makes `StartTransaction` the decisive call anyway (see the probe facts below). ✅ verified with a fake charge point: gun-2-only card → `Invalid`/tx 0 on gun 1, Accepted on gun 2.
Since 2026-07-11 a card can be **linked to a user and restricted per gun**:
- `"user": "julian"` on the allowlist entry ties the card to a user account — sessions started with it attribute to that person in the history, and the owner sees their card's sessions even without gun-wide permissions (ownership is looked up live, so linking is retroactive for history visibility).
- `"guns": ["eu092025:2"]` restricts the card to specific guns, **charger-qualified** (fnmatch patterns, so `"eu092025:*"` = all guns of one charger) — multi-charger-safe by construction. The check fires at `StartTransaction` (the only message that carries the connector); the preceding `Authorize` (tap) still says Accepted — harmless on this charger, because `AuthorizeRemoteTxRequests=false` makes `StartTransaction` the decisive call anyway (see the probe facts below). ✅ verified with a fake charge point: gun-2-only card → `Invalid`/tx 0 on gun 1, Accepted on gun 2.
Both are editable from the panel's Admin tab (owner dropdown + guns field).
## 2. By vehicle / chassis — ❌ CLOSED: not supported (2026-07-09)