#126 Read-only auditor role for the audit log
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/userswith"role": "auditor") and able to sign in with browser and CLI sessions. -
A new
require_audit_readercheck (root, admin, auditor) guardsGET /api/v1/audit-eventsandGET /api/v1/audit-events/verify, replacing the admin-only check there.dopbase audit verifyanddopbase audit exporttherefore work for auditors unchanged. -
Every other surface keeps auditors out:
require_metadata_accessandrequire_read_accessnow refuse the auditor role explicitly, so secret metadata, secret lists and layouts, environment and project data, and instance status return403; 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_auditorrebuildsadminswithauditorin the role check, since SQLite cannot alter a constraint. BecauseALTER TABLE RENAMEwith foreign keys enabled rewrites every other table's reference to the renamed name,sessionsis 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.rolenow 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
auditorin its role picker; accounts are created through the API, matching the API-first scope of [#120].
Verification
cargo fmt --checkcargo clippy --locked --all-targets --all-features -- -D warningscargo test: users 4 (new end-to-end test creates an auditor, signs in the waydopbase logindoes, 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-existingcommands::export::*failures need the util-linuxscriptbinary and are unrelated to this change.bun run test:docs,bun run test:github(17/17),bunx prettier --checkon 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.mdwhen public behavior changed, or explained why they are not needed. - [x] I updated relevan documentation inside
/docs
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.
Ticket changed by: dopbase