Menu ▾ ▴

#126 Read-only auditor role for the audit log

closed
nobody
None
2026-10-23
2026-10-17
Anonymous
No

Originally created by: bosd

Implements the fourth and final slice of [#119]: a read-only auditor role that can review and export the audit log without any access to secrets.

Stacked on [#125]: this branch builds on feat/audit-retention, so the PR currently shows that commit too. Once [#125] merges (or on a rebase) only the auditor commit remains; review 787c48d for this change.

Summary

  • New AdminRole::Auditor, creatable like any other human account (POST /api/v1/users with "role": "auditor") and able to sign in with browser and CLI sessions.

  • A new require_audit_reader check (root, admin, auditor) guards GET /api/v1/audit-events and GET /api/v1/audit-events/verify, replacing the admin-only check there. dopbase audit verify and dopbase audit export therefore work for auditors unchanged.

  • Every other surface keeps auditors out: require_metadata_access and require_read_access now refuse the auditor role explicitly, so secret metadata, secret lists and layouts, environment and project data, and instance status return 403; mutations, user/service-account administration, backups, and factory reset were already admin or root checks and continue to exclude auditors. Members keep exactly their previous access and still cannot read the audit log.

  • Migration 0017_admin_role_auditor rebuilds admins with auditor in the role check, since SQLite cannot alter a constraint. Because ALTER TABLE RENAME with foreign keys enabled rewrites every other table's reference to the renamed name, sessions is rebuilt after the swap: its rows and foreign key survive, no session is revoked, and the down migration mirrors the dance (dropping auditor accounts, which the old check cannot hold, and their sessions only).

  • Docs: identity reference gains the auditor column in the role matrix and the fifth-role wording, audit/API/CLI docs now say "administrator or auditor" where the log is read, and the CHANGELOG describes the scope.

Compatibility

  • Additive role: existing accounts and every existing access rule are unchanged; the only behavior change for current principals is that admins.role now accepts one more value.
  • The migration is reversible and both directions are exercised by the existing rollback/reapply migration test with rows present.
  • The Admin UI does not yet offer auditor in its role picker; accounts are created through the API, matching the API-first scope of [#120].

Verification

  • cargo fmt --check
  • cargo clippy --locked --all-targets --all-features -- -D warnings
  • cargo test: users 4 (new end-to-end test creates an auditor, signs in the way dopbase login does, reads the audit list and verify successfully, and is refused with 403 on instance status, projects, secret metadata, user listing, project creation, and service-account creation; also asserts members are refused the audit log), services 24 (migration apply/rollback/reapply covers the new pair), cli 212, main 27, config 22, constants 4, daemon 15, backups 9, server 6. The 3 pre-existing commands::export::* failures need the util-linux script binary and are unrelated to this change.
  • bun run test:docs, bun run test:github (17/17), bunx prettier --check on the changed Markdown.

Checklist

  • [x] I kept this pull request focused on one problem.
  • [x] I added or updated tests for behavior changes, or explained why tests are not needed.
  • [x] I updated the documentation and CHANGELOG.md when public behavior changed, or explained why they are not needed.
  • [x] I updated relevan documentation inside /docs

Related

Tickets: #119
Tickets: #120
Tickets: #125

Discussion

  • Anonymous

    Anonymous - 2026-10-23

    Originally posted by: dopbase

    Thankyou for your contributions, but this PR will not merged, because in next release 0.2.0 will have complete RBAC and it has auditor as well included.

     
  • Anonymous

    Anonymous - 2026-10-23

    Ticket changed by: dopbase

    • status: open --> closed
     

Log in to post a comment.