Repository navigation
feat: add password rotation policy - #14321
Conversation
🟢 Tier S · Ready to merge
Adds a project-level password-rotation policy that administrators can configure through the project policy API and SDK metadata. Email/password sign-in checks the password’s age against the policy’s maximum age in seconds and rejects expired credentials before creating a session; policy responses, defaults, security-route inventory, and E2E coverage are included. Latest changes: The newest commit replaces the policy’s day-based
Note @Indra55 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve. 📂 Walkthrough · 15
Reviewed the commits since |
Align with the OIDC maxAge param and other time spans in the API, which use seconds. Range is 1 day (86400) to 10 years (315360000), defaulting to 1 year (31536000). Co-Authored-By: Claude Opus 5.5 <[email protected]>
What does this PR do?
Adds a project-level password rotation policy that lets project administrators require users to reset passwords after a configurable period.
The policy is available through
PATCH /v1/project/policies/password-rotation, with SDK metadata forproject.updatePasswordRotationPolicy. It accepts:enabled: whether password rotation is enforced. Disabled by default.duration: maximum password age in days. Defaults to 365 days (1 year). Both defaults were specified by @Meldiron in Discord.Both parameters support partial updates, preserving the current value when omitted.
During email/password session creation, the policy checks the user's existing
passwordUpdatetimestamp after verifying their credentials. If the password is older than the configured duration, sign-in returns412 user_password_reset_requiredbefore creating a session or issuing a session cookie. Incorrect credentials continue to return the existing invalid-credentials error.Users can complete the existing password recovery flow, which refreshes
passwordUpdateand allows them to sign in again. Enforcement applies to new email/password sessions; enabling the policy does not revoke existing sessions.The implementation follows the existing project policy structure, including permission scopes, event and audit metadata, cache invalidation, and policy GET/list responses. Older projects without stored rotation settings default to disabled.
Includes E2E coverage for configuration, validation, permissions, password expiration, session rejection, and successful sign-in after recovery.
Test Plan
Ran:
Passed: 10 tests, 130 assertions, covering:
Pint and PHPStan checks also passed on all changed files.
Related PRs and Issues
Maintainer-assigned task discussed on Discord.
Checklist