Skip to content

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

  1. Expiry is computed, never stored. A password expires REQUIRE_PASSWORD_CHANGE_DAYS days after last_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 in app/utils/user_utils.py, and the list filter and dashboard count use one predicate in app/dashboard_metrics.py.

  2. No recorded date never expires, and 0 or less turns expiry off.

  3. An expired password restricts like a temporary one. get_current_user restricts when the stored flag is set or the password has expired. Everything else is ADR 0014's mechanism unchanged: the same 403 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.

  4. Responses report the effective value. needs_to_change_password in 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 carries password_expires_at, tz-aware UTC, or null when the password does not expire.

  5. Expiring includes expired. A password that expires within 14 days, or already has, counts as Expiring: the badge, the status=expiring list filter and the dashboard's passwords_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, which get_current_user leaves open to them. A deployment that wants no expiry sets REQUIRE_PASSWORD_CHANGE_DAYS=0 before upgrading.
  • A temporary password left unused past the window is also expired. It was already restricted.
  • The stored needs_to_change_password and the value in responses can differ. Code that decides on restriction uses password_change_required(), not the column.