Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
4.6 KiB
ADDED Requirements
Requirement: Admin writes are recorded
The system SHALL record an audit event for every state-changing admin API call made with a valid admin token, successful or not, holding the time, admin username, module, readable action code, HTTP method, path template (never the concrete path or query), target id, outcome with HTTP status, and client IP. Sign-in, sign-out, token refresh, forgot-password, own password change from the user menu, and calls without a valid admin token SHALL NOT be recorded.
Scenario: A user edit is recorded
- WHEN admin
adminupdates user 4 - THEN an audit event is saved with actor
admin, moduleBO_USERS, actionUSER_UPDATE, path templatePUT /api/admin/users/{id}, target4, outcomeSUCCESS, and the client IP
Scenario: A failed write is recorded
- WHEN an admin's role update is refused with status 400
- THEN an audit event is saved with outcome
FAILUREand status 400
Scenario: Sign-in is not recorded
- WHEN an admin signs in or signs out
- THEN no audit event is saved
Scenario: First-login password change is recorded
- WHEN a new admin sets their password at first login
- THEN an audit event with action
AUTH_FIRST_LOGINis saved
Requirement: Refused access is recorded
The system SHALL record an audit event with outcome FAILURE when a valid admin token is refused by the access check (missing module, super admin required, or pending first-login change).
Scenario: Missing module
- GIVEN admin
noeventshas noBO_EVENTS - WHEN
noeventstries to create an event - THEN the request is refused with 403
- AND an audit event with actor
noevents, moduleBO_EVENTSand outcomeFAILUREis saved
Requirement: Sensitive reads are recorded
The system SHALL record an audit event when an admin exports leads, exports event leads, or opens a saved email. Read-only POST calls marked as such SHALL NOT be recorded.
Scenario: Opening an email
- WHEN an admin opens email 12
- THEN an audit event with action
EMAIL_VIEWand target12is saved
Scenario: Lead export
- WHEN an admin downloads the lead export
- THEN an audit event with action
LEAD_EXPORTis saved
Requirement: Allow-listed changes
The system SHALL attach before and after values only for these fields: a user's role names and enabled flag, a role's granted module codes, and the login-security lockout settings and password rules. For lead and event-lead edits the system SHALL record only the names of the fields that changed, never their values. No audit event SHALL contain a password, token, raw request body, or lead name, phone, email or notes.
Scenario: Role change on a user
- WHEN an admin changes user 4's roles from
SalestoSales, Manager - THEN the event's changes show roles before
Salesand afterSales, Manager
Scenario: Lead edit records field names only
- WHEN an admin changes a lead's phone and notes
- THEN the event's changes list the fields
phoneandnotes - AND neither the old nor the new phone or notes appear in the event
Requirement: Recording never blocks the action
Recording SHALL be best-effort. A failure to publish or save an audit event MUST NOT change the response of the admin call.
Scenario: Publish failure
- GIVEN the audit event cannot be published
- WHEN an admin updates a user
- THEN the update succeeds as usual
- AND the failure is logged
Requirement: Retention
The system SHALL delete audit events older than the configured retention period, 730 days by default, on a schedule.
Scenario: Old events are purged
- WHEN the purge runs with a retention of 730 days
- THEN events older than 730 days are deleted
- AND newer events are kept
Requirement: Audit log screen
The system SHALL let an admin with BO_AUDIT_LOG list audit events newest first, paged, filtered by actor, module, action, outcome and date range, and open one event to see its details and changes. An admin without BO_AUDIT_LOG SHALL be refused.
Scenario: Filter by actor
- WHEN an admin with
BO_AUDIT_LOGfilters the audit log by actoradmin - THEN only events by
adminare listed, newest first
Scenario: Event detail
- WHEN an admin opens an event for a role grant change
- THEN the detail shows the event's fields and the modules added and removed
Scenario: Without the module
- WHEN an admin without
BO_AUDIT_LOGcalls the audit log API or opens/audit-log - THEN the API answers 403 and the page shows Not authorised