Skip to content

core: store passwords as authenticator devices - #24325

Merged
dominic-r merged 25 commits into
mainfrom
dominic/password-device
Nov 2, 2026
Merged

dominic-r merged 25 commits into
mainfrom
dominic/password-device

Conversation

@dominic-r

@dominic-r dominic-r commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Details

Base of the password lockout stack:

  1. core: store passwords as authenticator devices #24325 store passwords as authenticator devices (this PR)
  2. stages/password: lock password login after failed attempts #24794 lock password login after failed attempts
  3. web/admin: manage password lockout #24798 manage password lockout in the Admin interface
  4. website/docs: document password lockout #24799 document password lockout
  5. website/docs: add password lockout 2026.11 release notes #24801 2026.11 release notes

What does this PR change?

A user's password hash and change date move from User to a PasswordDevice owned by the password stage. A user without a device has no usable password. Password devices are not offered for MFA.

Code writes passwords with PasswordDevice.set_password(), set_password_from_hash() and set_unusable_password(). Each writes the device, then saves the user, so outgoing sync and cached policy results still see the change.

user.password and user.password_change_date stay readable, because property mappings (including the Google Workspace and Entra system blueprints) and Django's session hash use them. Django's own password writes on User now raise instead of silently doing nothing, so create_user(), ak changepassword and guardian's anonymous user go through the device or skip the password.

The migration copies usable passwords to devices. The old User columns stay, nullable, for a later release to drop. It also adds the lockout fields #24794 uses, so the stack has one migration per app.

Why is this change needed?

Lockout needs state per password (failed attempts, lock time) and lock and unlock endpoints. Storing the password as an authenticator device keeps that state next to the hash.

How was this tested?

Added tests for password writes (one device per user, a password change keeps a lock, every write saves the user, revoking creates no device, a hash upgrade loses to a concurrent reset), ak changepassword, async authentication, the data migration, user write rollback when LDAP or Kerberos refuses a password, and account lockdown on an inactive user. User, token, OAuth2 token and consent lists keep a constant number of password-device queries.

Ran the whole stack on a fresh database: logged in through the new backend, locked and unlocked a user from the Admin interface, and failed a login until the warning and then the lockout message appeared.

Screenshots

Password stage settings:

Password stage lockout settings

User actions, with the device's password change date:

User page with Lock password login

Lock confirmation

Unlock password login on a locked user

Login after two and three wrong passwords:

Last-attempt warning

Lockout message

Linked issues

None.


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

Copilot AI lite review requested due to automatic review settings July 23, 2026 16:08
@dominic-r
dominic-r requested review from a team as code owners July 23, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dominic-r
dominic-r marked this pull request as draft July 23, 2026 16:09
@dominic-r dominic-r self-assigned this Jul 23, 2026
@dominic-r dominic-r added this to the Release 2026.11.0: Required milestone Jul 23, 2026
@netlify

netlify Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit f534bfe
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a8f1e2e42e6ef000846d356
😎 Deploy Preview https://deploy-preview-24325--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit f534bfe
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a8f1e2eaba922000894adcb
😎 Deploy Preview https://deploy-preview-24325--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.22785% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.78%. Comparing base (9b1f40a) to head (74aae49).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
authentik/core/models.py 91.30% 2 Missing ⚠️
authentik/core/auth.py 91.66% 1 Missing ⚠️
...hentik/enterprise/stages/account_lockdown/stage.py 88.88% 1 Missing ⚠️
authentik/outposts/models.py 66.66% 1 Missing ⚠️
authentik/policies/expiry/models.py 50.00% 1 Missing ⚠️
authentik/stages/password/models.py 98.24% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #24325       +/-   ##
===========================================
+ Coverage   69.26%   92.78%   +23.52%     
===========================================
  Files        1204     1206        +2     
  Lines       82456    82731      +275     
  Branches     4686     4686               
===========================================
+ Hits        57111    76764    +19653     
+ Misses      25269     5891    -19378     
  Partials       76       76               
Flag Coverage Δ
conformance 30.84% <21.26%> (+0.28%) ⬆️
e2e 35.64% <27.84%> (?)
integration 28.31% <16.20%> (-0.04%) ⬇️
rust 49.31% <ø> (ø)
unit 94.34% <97.97%> (+24.94%) ⬆️
unit-migrate 94.33% <97.97%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@dominic-r
dominic-r force-pushed the dominic/password-device branch from 23fdf85 to 75e3a87 Compare August 5, 2026 23:07
Copilot AI review requested due to automatic review settings August 5, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dominic-r
dominic-r marked this pull request as ready for review August 5, 2026 23:07
@dominic-r
dominic-r removed request for a team August 5, 2026 23:07
Comment thread authentik/core/models.py Fixed
Copilot AI review requested due to automatic review settings August 5, 2026 23:19
@dominic-r
dominic-r force-pushed the dominic/password-device branch from 75e3a87 to f4aa26e Compare August 5, 2026 23:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-f65d554379b4753038c781bc4b5e889da1f34c0c
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-f65d554379b4753038c781bc4b5e889da1f34c0c

Afterwards, run the upgrade commands from the latest release notes.

Copilot AI review requested due to automatic review settings August 7, 2026 14:49
@dominic-r
dominic-r force-pushed the dominic/password-device branch from f4aa26e to b168406 Compare August 7, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dominic-r
dominic-r force-pushed the dominic/password-device branch from b168406 to f65d554 Compare August 9, 2026 17:15

@dominic-r dominic-r left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

BeryJu
BeryJu previously requested changes Aug 11, 2026

@BeryJu BeryJu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the password stage as is it kinda breaks how authenticators work where a specific type configures the type of authenticator and the validation stage validates any of them, where as this one is configured via prompt.

in an ideal world, the authenticator_* stages would both configure and validate authenticators and the authenticator_validation stage would only exist to choose a type, and you could just go backwards within a flow, but that's a big change and a lot of consequences

Comment thread authentik/core/models.py Resolved
Drop the PasswordUser adapter that staged password writes on the user
until save(). Callers now use PasswordDevice.set_password(),
set_password_from_hash() and set_unusable_password(), which write the
device immediately and then save the user, so outgoing sync and the
policy cache still see password changes.

User keeps read-only password and password_change_date properties
because property mappings (including the Google Workspace and Entra
system blueprints) and Django's session hash read them. Django's
password writes on User now raise instead of assigning the property, so
create_user(), `ak changepassword` and guardian's anonymous user go
through the device or skip the password.

The data migration copies passwords in Python with chunked_queryset and
skips unusable passwords, since a user without a device has no usable
password. It no longer copies passwords back on downgrade; the legacy
columns stay in place until a later release.
@dominic-r
dominic-r dismissed BeryJu’s stale review November 1, 2026 17:26

blocking changes are from aug 11 and have since long been applied

@dominic-r
dominic-r merged commit 23d5877 into main Nov 2, 2026
171 checks passed
@dominic-r
dominic-r deleted the dominic/password-device branch November 2, 2026 16:57
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Nov 2, 2026
jsachs added a commit that referenced this pull request Nov 5, 2026
Instead of dropping the `acs_url` column when migrating to `_acs_urls`,
keep it as the deprecated `legacy_acs_url` field (still stored in the
`acs_url` column), so instances running a previous version keep working
during an upgrade. This follows how #24325 kept the legacy password
columns.

The column is kept in sync with the default ACS URL whenever a provider
is saved, so older instances see the current value. It isn't exposed in
the API or as a filter; `acs_url` in the API keeps using the default ACS
URL from the list.

The column should be dropped in the release after 2026.11, noted with a
TODO on the field.
jsachs added a commit that referenced this pull request Nov 5, 2026
Instead of dropping the `acs_url` column when migrating to `_acs_urls`,
keep it as the deprecated `legacy_acs_url` field (still stored in the
`acs_url` column), so instances running a previous version keep working
during an upgrade. This follows how #24325 kept the legacy password
columns.

The column is kept in sync with the default ACS URL whenever a provider
is saved, so older instances see the current value. It isn't exposed in
the API or as a filter; `acs_url` in the API keeps using the default ACS
URL from the list.

The column should be dropped in the release after 2026.11, noted with a
TODO on the field.
jsachs added a commit that referenced this pull request Nov 5, 2026
Instead of dropping the `acs_url` column when migrating to `_acs_urls`,
keep it as the deprecated `legacy_acs_url` field (still stored in the
`acs_url` column), so instances running a previous version keep working
during an upgrade. This follows how #24325 kept the legacy password
columns.

The column is kept in sync with the default ACS URL whenever a provider
is saved, so older instances see the current value. It isn't exposed in
the API or as a filter; `acs_url` in the API keeps using the default ACS
URL from the list.

The column should be dropped in the release after 2026.11, noted with a
TODO on the field.
BeryJu pushed a commit that referenced this pull request Nov 16, 2026
Instead of dropping the `acs_url` column when migrating to `_acs_urls`,
keep it as the deprecated `legacy_acs_url` field (still stored in the
`acs_url` column), so instances running a previous version keep working
during an upgrade. This follows how #24325 kept the legacy password
columns.

The column is kept in sync with the default ACS URL whenever a provider
is saved, so older instances see the current value. It isn't exposed in
the API or as a filter; `acs_url` in the API keeps using the default ACS
URL from the list.

The column should be dropped in the release after 2026.11, noted with a
TODO on the field.
jsachs added a commit that referenced this pull request Nov 17, 2026
Instead of dropping the `acs_url` column when migrating to `_acs_urls`,
keep it as the deprecated `legacy_acs_url` field (still stored in the
`acs_url` column), so instances running a previous version keep working
during an upgrade. This follows how #24325 kept the legacy password
columns.

The column is kept in sync with the default ACS URL whenever a provider
is saved, so older instances see the current value. It isn't exposed in
the API or as a filter; `acs_url` in the API keeps using the default ACS
URL from the list.

The column should be dropped in the release after 2026.11, noted with a
TODO on the field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants