Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
3.8 KiB
3.8 KiB
Proposal
Why
Go-live is 2027-01-15. Today the admin login counts nothing: anyone who reaches the login page can guess passwords without limit, and nothing records who signed in. Staff also cannot change their own password; only an admin can set a temporary one for them.
The legacy backoffice blocked a username after 3 failed logins, using an in-memory counter. Co-Lite's new login path (portal, then mobile-api, then services-auth) never ported that rule. babyboo solved the same gap with a persisted login_audit table, and this change follows it, trimmed to what Co-Lite needs. The history it keeps will also serve the later audit-log viewer.
Design: docs/superpowers/specs/2026-11-30-admin-login-security-design.md.
What Changes
- Login history: every admin login success, failure, locked refusal, logout, unlock and own password change is saved to a new
service-system.login_audittable. Each row has the time, username, client IP and user agent. - Lockout:
- After a set number of failed logins inside a set period, the username is locked. The defaults are 5 attempts in 15 minutes.
- A locked username is refused even with the right password.
- The lock ends by itself when the failures age out, or when an admin unlocks it.
- The settings reuse the existing
ADMIN_LOGIN_BLOCKrows insystem_property, plus one new row for the maximum attempts.
- Enforcement point: mobile-api
AdminAuthController.login, the only way in (only the admin portal is public). services-auth is not changed. - Change my password: a new
POST /api/admin/auth/change-passwordand a dialog in the portal's user menu. It needs the current password and applies the admin password rules. A wrong current password counts as a failed login. - Login security screen (
/login-security, moduleBO_LOGIN_SECURITY):- History tab: login history with filters.
- Locked tab: locked usernames with an Unlock button.
- Settings tab: edits the lockout settings and the admin password rules (
ADMIN_PWD_FORMAT).
- Login page: shows a clear message when the username is locked.
- Not in this change: session policy (logout revocation, sliding sessions, single session), MFA, CAPTCHA, password aging, member or other non-admin logins, and purging old history.
Capabilities
New Capabilities
admin-login-security: the login history, the lock rule and its enforcement on admin login, unlock, the lockout and password-rule settings, and the Login security screen.admin-own-password: an admin changing their own password.
Modified Capabilities
None.
Impact
solvway-services-system:- A new
LoginAuditentity and repository, a service and a/loginSecuritycontroller (isLocked, record, audit, locked, unlock, config, password rules). - A new
/user/changeAdminPasswordendpoint that checks the current password with the existingBCryptPasswordEncoder.
- A new
solvway-mobile-api:AdminAuthControllerlogin and logout record events and check the lock.- New
change-passwordendpoint. - New
AdminLoginSecurityControllerunderBO_LOGIN_SECURITY.
solvway-admin-portal:- The login and logout proxy routes forward the client IP and user agent.
- The login page shows the locked message.
- Change-password dialog in the header.
- New
/login-securitypage with proxy routes, a service and i18n keys.
- Database (
sql/in this change, mirrored inlocal/seed/03-colite.sql):- Create
login_audit, withcompany_id. - Insert
ADMIN_LOGIN_MAX_ATTEMPT. - Set the block period to 15 minutes.
- Insert the
BO_LOGIN_SECURITYmodule row. - A rollback script.
- Create
- Security: this changes the admin sign-in path. The lock check fails open when services-system errors, so an outage cannot lock everyone out. The audit write is best-effort.
- Docs:
docs/deployment.mdlists the new SQL. - No new dependency.