From 81ef54f996d02a18c08765bc3a5c32f977af2430 Mon Sep 17 00:00:00 2001 From: ngqile Date: Mon, 30 Nov 2026 17:01:55 +0800 Subject: [PATCH] docs: audit log deploy SQL, topic and retention setting Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- docs/deployment.md | 14 ++++++++++++++ openspec/changes/add-admin-audit-log/tasks.md | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/deployment.md b/docs/deployment.md index 6ec1d04..40bb31b 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -82,6 +82,13 @@ After running `04`, `SELECT LENGTH(password) FROM \`service-system\`.\`user\` WH `99-rollback.sql` in the same folder undoes the three and deletes the login history. +| File | What it does | +|---|---| +| `openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/01-audit-event.sql` | Creates `service-log`.`audit_event` (the admin audit trail). DDL: run it with a user that may create tables, not the services' user. | +| `openspec/changes/archive/2026-11-30-add-admin-audit-log/sql/02-audit-log-module.sql` | Adds the Audit log back-office module (`BO_AUDIT_LOG`). No role gets it; super admins grant it under Roles. | + +`99-rollback.sql` in the same folder undoes the two and deletes the audit trail. + **Database user:** - Create one user with `SELECT, INSERT, UPDATE, DELETE, EXECUTE` on the five schemas. EXECUTE is needed: service-member calls a stored function. - Every Java service reads the same variables (section 6): `MYSQLHOST`, `MYSQLPORT`, `MYSQLUSER`, `MYSQLPWD`. @@ -98,6 +105,7 @@ The services publish and subscribe through Google Pub/Sub. It is not replaced in - **Project:** use a Google Cloud project, and give its id as `GCP_PROJECT`. - **Service account:** create one with the Pub/Sub Publisher and Pub/Sub Subscriber roles, and download a JSON key. Mount the key into every Java image except `api-gateway` (section 7), and set `GCP_CREDENTIAL_FILE=file:/var/secrets/gcp/key.json`. - **Topics and subscriptions:** use `local/pubsub/topics.txt`. Each line is a topic name, optionally followed by a subscription name. Some topics appear on several lines with different subscriptions (e.g. `update-sync-topic`): create each topic once, then every subscription listed for it. Subscriptions use default settings. +- **Audit log:** `audit-event-topic` with `audit-event-subscription` carries admin audit events from mobile-api to service-log. It is in `topics.txt`; service-log also creates both at startup if they are missing. ## 6. Environment variables @@ -160,6 +168,12 @@ The keys: | `JWT_SECRET` | Secret | Same value as `JWT_TOKEN` | | `CUSTOMER_PORTAL_BASE_URL` | Plain | The customer portal is not deployed in phase 1. When unset, it falls back to a Tastefully address that only the member referral link uses, which Co-Lite does not use. Set it once a customer portal exists. | +**`service-log`:** + +| Variable | Kind | Value | +|---|---|---| +| `AUDIT_RETENTION_DAYS` | Plain | Optional (default 730). Admin audit events older than this many days are deleted daily at 03:30. | + **`api-gateway`:** only `JWT_TOKEN` (same value as everywhere). No Pub/Sub, Redis or database settings, and no `key.json` mount. It reads its client keys from the mounted `appkeys.json` (section 7). **`admin-portal`:** diff --git a/openspec/changes/add-admin-audit-log/tasks.md b/openspec/changes/add-admin-audit-log/tasks.md index 59b0e5c..b8f1328 100644 --- a/openspec/changes/add-admin-audit-log/tasks.md +++ b/openspec/changes/add-admin-audit-log/tasks.md @@ -78,7 +78,7 @@ Design: `design.md`. All tasks run serially: each builds on the one before. ## 5. Check and docs -- [ ] 5.1 Browser check and handover. +- [x] 5.1 Browser check and handover. - Playwright on the local stack: - as admin, change a user's roles, change a role's grants, edit a lead, open an email and export leads, then see each in Audit log with its changes; - as `noevents`, try a forbidden action and see it as `FAILURE`;