Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
61 lines
3.6 KiB
Markdown
61 lines
3.6 KiB
Markdown
# 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 `AppAccessAspect` publishes 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_audit` covers them or there is no actor.
|
|
- **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 on `audit-event-subscription` and saves to a new `service-log`.`audit_event` table. 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-log` and `GET /api/admin/audit-log/{id}` under the new module `BO_AUDIT_LOG`.
|
|
- **Portal:** a new `/audit-log` page 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/save` and `back_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 new `AuditEvent` message class shared by mobile-api and services-log.
|
|
- **`solvway-services-log`:**
|
|
- `AuditEventLog` entity and repository;
|
|
- the topic and subscription setup and the listener;
|
|
- the purge;
|
|
- `/log/audit/search` and `/log/audit/{id}`.
|
|
- **`solvway-mobile-api`:**
|
|
- the `Audited` annotation and the `AuditChanges` request 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`.
|
|
- **`solvway-admin-portal`:** the `/audit-log` pages, 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.txt` and `docs/deployment.md` section 5.
|
|
- **Database:** `sql/01-audit-event.sql` (DDL in `service-log`) and `sql/02-audit-log-module.sql`, mirrored in `local/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.
|