ADR 0016: Password expiry restricts like a temporary password¶
Status¶
Accepted. Supersedes the last consequence of ADR 0014, which left time-based expiry out of scope.
Context¶
Settings.REQUIRE_PASSWORD_CHANGE_DAYS has existed with a default of 90, and nothing read it. The web app showed a 90-day expiry computed in the browser, and a password older than that kept full access (#425). That is the state ADR 0011 decision 4 objects to: a name that asserts a control that does not exist.
ADR 0014 already gives an account a restricted state: sign-in succeeds, and until the password changes the user can only change it, read their own profile and log out.
Decision¶
-
Expiry is computed, never stored. A password expires
REQUIRE_PASSWORD_CHANGE_DAYSdays afterlast_changed_password_date. There is no column and no migration. Every password change already writes that date in one place, and a changed setting applies to every user at once. The rule lives inapp/utils/user_utils.py, and the list filter and dashboard count use one predicate inapp/dashboard_metrics.py. -
No recorded date never expires, and
0or less turns expiry off. -
An expired password restricts like a temporary one.
get_current_userrestricts when the stored flag is set or the password has expired. Everything else is ADR 0014's mechanism unchanged: the same403 password_change_required, the same four opt-in routes, superusers included, the row read on every request rather than a token claim, and sign-in unchanged. -
Responses report the effective value.
needs_to_change_passwordin a user response is true for a temporary or an expired password, so clients need no new signal. Expiry never writes the column. Each user response also carriespassword_expires_at, tz-aware UTC, ornullwhen the password does not expire. -
Expiring includes expired. A password that expires within 14 days, or already has, counts as Expiring: the badge, the
status=expiringlist filter and the dashboard'spasswords_expiring_soon. The status badge set has no separate Expired state.
Considered options¶
Store password_expires_at. Rejected: a stored value keeps the old window until each user's next change, so changing the setting would need a backfill, and every password path would have a second field to keep in step.
Set needs_to_change_password when a password expires. Rejected: it needs a scheduled job, lags the expiry by up to one run, and a raised setting could not release the users already flagged.
A separate refusal code and signal for expiry. Rejected: the user does the same thing in both cases. The web app words its page from password_expires_at.
Consequences¶
- On upgrade, every account whose password is older than the window is restricted at its next request, superusers and accounts used by scripts included. Those clients must call
POST /auth/change_password, whichget_current_userleaves open to them. A deployment that wants no expiry setsREQUIRE_PASSWORD_CHANGE_DAYS=0before upgrading. - A temporary password left unused past the window is also expired. It was already restricted.
- The stored
needs_to_change_passwordand the value in responses can differ. Code that decides on restriction usespassword_change_required(), not the column.