From e240a9c37fb530bfe55bae7feba0f1e8fc337f22 Mon Sep 17 00:00:00 2001 From: ngqile Date: Mon, 30 Nov 2026 14:52:15 +0800 Subject: [PATCH] docs: login security SQL and lockout notes in the deployment guide Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- docs/deployment.md | 6 ++++++ openspec/changes/add-admin-login-security/tasks.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/deployment.md b/docs/deployment.md index b0330e3..7ab990a 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -76,6 +76,11 @@ After running `04`, `SELECT LENGTH(password) FROM \`service-system\`.\`user\` WH | File | What it does | |---|---| | `openspec/changes/archive/2026-11-30-add-admin-email-listing/sql/01-email-module.sql` | Adds the Emails back-office module (`BO_EMAILS`). | +| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/01-login-audit.sql` | Creates the `login_audit` table (admin login history; the lockout reads it). DDL: run it with a user that may create tables, not the services' user. | +| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/02-lockout-settings.sql` | Adds `ADMIN_LOGIN_MAX_ATTEMPT` (5) and sets the admin block period to 15 minutes: 5 failed sign-ins in 15 minutes lock the username. | +| `openspec/changes/archive/2026-11-30-add-admin-login-security/sql/03-login-security-module.sql` | Adds the Login security back-office module (`BO_LOGIN_SECURITY`). | + +`99-rollback.sql` in the same folder undoes the three and deletes the login history. **Database user:** - Create one user with `SELECT, INSERT, UPDATE, DELETE, EXECUTE` on the five schemas. EXECUTE is needed: service-member calls a stored function. @@ -264,6 +269,7 @@ data: ## 10. Known gaps at go-live - **No email provider yet.** Staff onboarding does not need one: the admin types each new user's first password, and "Set temporary password" on a user's page unlocks a user who forgot theirs. Both force a password change at the next sign-in. Forgot-password and "Send password reset" still create an email with a temporary password. Nobody receives it, but `service-email` saves every email first, so a super admin (or a role granted Emails) can read it under **Emails** and pass the password on in person. The user must change it at the next sign-in. Grant Emails narrowly: it shows every saved email, including other users' temporary passwords, member email-verification codes, and contact or distributor form submissions with the sender's personal data. +- **Sign-in lockout.** 5 failed sign-ins within 15 minutes lock a username for 15 minutes, even with the right password, and unknown usernames are counted too. Anyone who knows a username can therefore lock it on purpose. An admin with **Login security** can unlock it at once (Locked tab), and can change the limits there. If every super admin is locked, wait out the period. The lock check fails open: if `service-system` is down, sign-in still works without the lockout. - **Reference data from Tastefully.** It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live. - **Other Tastefully defaults.** The sender addresses in `service-email` and the `CUSTOMER_PORTAL_BASE_URL` fallback point at Tastefully. Override them as described in section 6. - **Leaked SMS key.** An SMS360 API key from Tastefully was in `service-email`'s config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account. diff --git a/openspec/changes/add-admin-login-security/tasks.md b/openspec/changes/add-admin-login-security/tasks.md index b3a7743..23fc112 100644 --- a/openspec/changes/add-admin-login-security/tasks.md +++ b/openspec/changes/add-admin-login-security/tasks.md @@ -112,7 +112,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, with made-up local users:** - fail sign-in until locked and see the locked message; - as admin, see the user under Locked, unlock them, and they sign in;