Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
3.6 KiB
3.6 KiB
Proposal
Why
Nothing in Co-Lite records who did what in the admin portal. When an admin edits a user, changes a role's grants, edits or exports leads, or opens a saved email (which can hold a temporary password), the only trace is a line in the application log. Sign-ins are the exception: login_audit covers them. Go-live is 2027-01-15, and the company needs an audit trail and a screen to read it.
babyboo built the same thing (add-portal-audit-log, archive 2026-11-19, plus audit-log-readable-actions, 2026-11-20). This change ports the admin half of that work, trimmed.
Design: docs/superpowers/specs/2026-11-30-admin-audit-log-design.md.
What Changes
- Recording:
- mobile-api's
AppAccessAspectpublishes an audit event for every admin write under/api/admin/**, every refusal of a valid admin token, and three sensitive reads: the lead export, the event-lead export and opening an email. - Sign-in, sign-out, refresh, forgot-password and own password change are not recorded, because
login_auditcovers them or there is no actor.
- mobile-api's
- Each event:
- who and when; the module and a readable action code;
- the method and the path template; the target id;
- the outcome and status, and the browser IP.
- Before/after values only for an allow-list:
- a user's role names and enabled flag;
- role module grants;
- login-security settings;
- for lead edits and event-lead edits, the names of the changed fields only, never the values.
- Transport: a new Pub/Sub topic
audit-event-topic. services-log subscribes onaudit-event-subscriptionand saves to a newservice-log.audit_eventtable. Publishing is best-effort: a failure never blocks the admin's action. - Retention: services-log deletes events older than
AUDIT_RETENTION_DAYS(default 730) on a schedule. - Reading: services-log gets search and detail endpoints. mobile-api gets
GET /api/admin/audit-logandGET /api/admin/audit-log/{id}under the new moduleBO_AUDIT_LOG. - Portal: a new
/audit-logpage with a list, filters and a detail view that shows the changes. - Not in this change:
- member and public calls;
- page views;
- removing the unused legacy
/log/saveandback_office_access_log.
Capabilities
New Capabilities
admin-audit-log: recording admin actions, refusals and sensitive reads; the allow-listed changes; retention; and the Audit log screen.
Modified Capabilities
None.
Impact
solvway-core-libs: a newAuditEventmessage class shared by mobile-api and services-log.solvway-services-log:AuditEventLogentity and repository;- the topic and subscription setup and the listener;
- the purge;
/log/audit/searchand/log/audit/{id}.
solvway-mobile-api:- the
Auditedannotation and theAuditChangesrequest holder; - publishing in
AppAccessAspect; - annotations on the sensitive reads and the read-only POST;
- changes supplied by the user, role, lead, event-lead and login-security services;
AdminAuditLogController.
- the
solvway-admin-portal: the/audit-logpages, a proxy, a service and i18n keys. Client IP is already forwarded on every call.- Pub/Sub: a new topic and subscription. They go in
local/pubsub/topics.txtanddocs/deployment.mdsection 5. - Database:
sql/01-audit-event.sql(DDL inservice-log) andsql/02-audit-log-module.sql, mirrored inlocal/seed/03-colite.sql, plus a rollback script. - Privacy: no passwords, tokens, request bodies or lead personal data are stored. User role names and login-security settings are stored as values.
- No new dependency.