ICD-003 — Cathode Ray admin interface
|
|
| Interface |
admin browser (the server's own web page) ⇄ Cathode Ray server |
| API version |
2 (path prefix /api/v2/admin) |
| Document revision |
1.2 (draft for review) |
| Normative artefacts |
this document, schema/icd-003.schema.json, examples/ |
| Related |
ICD-002 §2 (keys and scopes), ICD-001 v2 §12 (viewer scopes) |
The key words MUST, MUST NOT, SHOULD, SHOULD NOT and MAY are used as in RFC 2119.
1. Purpose
A small website served by the Cathode Ray server itself. It holds the global settings: what exists and who
may use it. Per-glasses settings live in the app (see ARCHITECTURE.md in the repository root).
Public, no password:
- Documentation: the ICDs, an API reference and quick-start snippets
Behind the password:
- Keys: create, change scopes and prefixes, restrict networks, disable, rotate, delete
- Pushed channels: see what's live, who pushed it and how fresh it is; delete leftovers
- Audit log: logins, key changes and (from phase 4) action invocations
The page and its API ship in the same container, at the same origin as everything else. Nothing here is used by the glasses.
The server is reachable from the internet and does not filter by network: the docs are public, the producer API is open to any holder of a key, and the admin page is protected by its password alone (§3.5).
2. Pages
| Path |
Content |
/docs/ |
Documentation, public, no login: the ICDs shipped in the image (rendered Markdown), the API reference generated from the server's OpenAPI description, and quick starts (push a value, connect the glasses, set up Grafana). /docs redirects to /docs/. |
/docs/icd/{name} |
One ICD as rendered Markdown (icd-001-v2, icd-002, icd-003) |
/docs/openapi.json |
OpenAPI 3 description of the HTTP APIs (ICD-002, ICD-003, helper endpoints of ICD-001 v2 §3.2) |
/admin/ |
Login form, or the app when a session exists |
/admin/#keys |
Key table: name, scopes, prefixes, networks, enabled, last used. Create, edit, rotate, delete. |
/admin/#channels |
Pushed channels: id, label, value, unit, state, age, owning key. Delete. |
/admin/#audit |
Newest 500 audit events |
The pages are static HTML, CSS and JS. They use only the API below and no third-party resources.
The docs are public on purpose: they're the manual for anyone who gets a key. Security never depends on the docs
being secret. They MUST NOT contain secrets, key material or deployment details (internal addresses, source
URLs); examples use placeholders such as $CATHODE_RAY_PUSH_KEY. The framework's built-in API explorer at its
default paths is switched off; /docs/ replaces it.
Docs responses are static and cacheable, and carry the same Content-Security-Policy and
X-Content-Type-Options headers as §3.4, but not Cache-Control: no-store.
When a key is created or rotated, the secret is shown once. It comes with a copy button and the matching snippets:
- a
curl push example for push keys
- the server URL plus key for viewer keys, to type into the phone app
- the Grafana contact point settings for
alerts keys
3. Authentication
3.1 Password
- One admin account, no username. The server reads an Argon2id hash from
CATHODE_RAY_ADMIN_PASSWORD_HASH.
- Create the hash with
docker compose run --rm cathode-ray cathode-ray hash-password. It prompts twice, refuses passwords shorter than 16 characters (the login is reachable from the internet), and prints the hash for .env.
- If the variable is unset, the admin interface is disabled.
/admin/ and /api/v2/admin/* answer 404. There is no default password.
- Changing the password means changing
.env and restarting. That also ends every session.
3.2 Login and sessions
POST /api/v2/admin/login {password}:
- Correct password:
204, with
Set-Cookie: cr_admin=<32 random bytes, base64url>; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=43200.
- Wrong password:
401 after a fixed 500 ms delay. The response is identical for every failure.
- Sessions live in server memory, so a restart logs everyone out.
- Idle timeout: 2 h.
- Absolute lifetime: 12 h.
POST /api/v2/admin/logout ends the session. It returns 204 and clears the cookie.
GET /api/v2/admin/session returns {expires_at, idle_expires_at}, or 401 without a session.
3.3 Brute-force protection
| Limit |
Effect |
| 5 failed logins per client IP in 5 min |
that IP gets 429 LOCKED on login for 15 min; audit event login_locked |
| 20 failed logins in total per hour |
throttled, not locked: every login attempt (right or wrong) is handled one at a time and takes 5 s instead of 500 ms until the count drops below 20; audit event login_throttled once per episode |
There is deliberately no global lockout: with the page on the internet, an attacker could use it to keep the
admin out for good. Throttling slows distributed guessing, but the real defence is the long password (§3.1).
The client IP is taken from X-Forwarded-For only when the request comes from the proxy network.
3.4 Request protection
- CSRF: every
POST, PATCH and DELETE (except login) MUST carry the header X-Cathode-Ray-Admin: 1. Without it, the server answers 403 FORBIDDEN.
- Browsers can't send custom headers cross-site without a CORS preflight, and the server sends no CORS headers.
- Together with
SameSite=Strict, that blocks cross-site requests.
- Headers on every admin response:
Content-Security-Policy: default-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer
Cache-Control: no-store
- Inline scripts: the page uses none, so the CSP works without
unsafe-inline.
3.5 Network exposure
The whole server is published at one hostname, with no IP filtering in nginx. Who may reach what is decided by the server itself:
| Path |
Reachable from |
Protection |
/ws/v2 |
anywhere |
viewer key (ICD-001 v2 §12) |
/api/v2/values, /activities, /alerts/grafana |
anywhere |
producer key with scope and prefix (ICD-002 §2) |
/api/v2/health |
anywhere |
none |
/docs/ |
anywhere |
none (public documentation) |
/admin/, /api/v2/admin/* |
anywhere |
the admin password (§3.1–§3.4) |
The password is therefore the only wall in front of the admin page. That is why it has a minimum length, why
login is rate-limited per IP (§3.3), and why the session cookie is HttpOnly; Secure; SameSite=Strict (§3.2).
An operator who wants a second wall can add an allow/deny block for /admin and /api/v2/admin in nginx; the
server doesn't depend on one and the ICD doesn't require it.
4. API
All bodies are application/json. Errors use the ICD-002 problem format ({"error": {code, message, details?}}), plus the code LOCKED (429, login lockout).
| Method and path |
Body → response |
POST /login |
LoginRequest → 204 + cookie |
POST /logout |
— → 204 |
GET /session |
→ Session |
GET /keys |
→ KeyList |
POST /keys |
KeyCreate → 201 KeyCreated |
PATCH /keys/{name} |
KeyPatch → 200 KeyView |
POST /keys/{name}/rotate |
— → 200 KeyCreated (the old secret stops working immediately) |
DELETE /keys/{name} |
→ 204 |
GET /channels |
→ ChannelList (pushed channels only) |
DELETE /channels/{id} |
→ 204 |
GET /audit?limit=100 |
→ AuditList (newest first, limit ≤ 500) |
All paths are relative to /api/v2/admin.
4.1 Key rules
The rules from ICD-002 §2 are enforced here, with 422 INVALID and per-field details:
name is an Id, unique (409 CONFLICT), and can't be changed. To rename, create a new key and delete the old one.
push and activity need at least one prefix.
- Prefixes MUST NOT be the first segment of a configured channel. For example,
printer belongs to the OctoPrint source, so no push key can take it.
allow_from entries are IPv4 or IPv6 CIDRs.
- Disabling, rotating or deleting a key closes its open viewer sessions (
4001) at once.
- Last-key guard: the server refuses to delete or disable the last enabled key that has the
view scope, because that would lock the glasses out. It returns 409 CONFLICT with an explanation.
4.2 KeyView: what the browser sees
| Field |
Meaning |
name, scopes, prefixes, allow_from, enabled |
as stored |
created, rotated, last_used |
Unix seconds. last_used is updated at most once per minute. |
secret_hint |
type prefix + last 4 characters, e.g. pk_…x7Qa, so you can recognise a key |
The SHA-256 hash is never sent to the browser.
4.3 Audit events
/data/audit.jsonl keeps the newest 10 000 events. Each event has ts, event, actor and optional target, ip and detail.
| event |
actor |
target |
login, login_failed, login_locked, login_throttled, logout |
admin |
— |
key_created, key_updated, key_rotated, key_deleted |
admin |
key name |
channel_deleted |
admin |
channel id |
action_invoked (phase 4) |
key name |
action id |
Secrets and passwords never appear in the audit log.
5. Storage
File in the /data volume |
Content |
Written |
keys.json |
key registry (ICD-002 KeyEntry[]) |
atomically, via a temp file and rename, on every change |
audit.jsonl |
audit events |
appended |
quickviews.json |
quick views (ICD-001 v2 §11) |
atomically |
The volume belongs on Indium's backup path. Losing keys.json means re-issuing every key.
6. Change log
| Rev |
Date |
Change |
| 1.0 |
2026-10-05 |
Draft: password login, sessions, CSRF rule, brute-force limits, key, channel and audit API |
| 1.1 |
2026-10-05 |
/docs/ documentation pages (no password, LAN-only); scope defined as global settings |
| 1.2 |
2026-10-06 |
Everything is internet-reachable. /docs/ is public (added /docs/icd/{name}, /docs/openapi.json). Admin is protected by the password only: 16-character minimum, per-IP lockout kept, global lockout replaced by throttling (login_throttled). LAN-only nginx rule removed; §3.5 is now an exposure table. |