Skip to content

Read-only accounts and an activity log - #101

Merged
XNinety9 merged 1 commit into
devfrom
feat/roles-audit
Oct 1, 2026
Merged

XNinety9 merged 1 commit into
devfrom
feat/roles-audit

Conversation

@XNinety9

@XNinety9 XNinety9 commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Fixes #100

Roles

  • users.role (migration 0022): admin (default, also for existing accounts) or viewer.
  • require_user refuses viewers' non-GET requests with 403, except /api/devices/{id}/logs/watch|stop. API tokens act with their account's role.
  • /api/auth/status returns the role; the dashboard hides every control that changes something for viewers and shows "read-only" next to the name.
  • CLI: create-user --role viewer, set-role <user> <role>, roles in list-users.

Activity log

  • audit_events (same migration), written by AuditMiddleware: a plain ASGI middleware (SSE and long polls pass straight through) recording each UI-API write once answered: user, via token or not, method, path, HTTP status, and a readable text.
  • The main endpoints describe() what they did: deployments (to which devices or tags), uploads, deletions, commands (name only, never arguments), configuration (keys only, never values), tags/renames/channels, access changes, staged rollouts and their actions. Others fall back to the endpoint name and ids.
  • GET /api/audit; an Activity dialog in the header. Pruned after 90 days.

Tests: viewer refused on writes but allowed to read and watch logs, set-role, readable log entries with no secret in them. Checked in Chromium as admin and viewer.

🤖 Generated with Claude Code

- Accounts are admin (the default, existing ones too) or viewer: viewers
  see everything and change nothing, except watching live logs. The
  server refuses their writes (API tokens act with their account's
  role); the dashboard hides the controls. CLI: create-user --role,
  set-role; list-users shows roles.
- Every write through the UI API is logged once answered (who, through a
  token or not, what, the HTTP status), by a plain ASGI middleware that
  leaves streams alone. The main endpoints describe what they did in
  words; command arguments and configuration values stay out. Kept 90
  days, shown under Activity in the dashboard.

Fixes #100
@XNinety9
XNinety9 merged commit 7044225 into dev Oct 1, 2026
12 checks passed
@XNinety9
XNinety9 deleted the feat/roles-audit branch October 1, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read-only accounts and an activity log

1 participant