Repository navigation
core: store passwords as authenticator devices - #24325
Conversation
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
23fdf85 to
75e3a87
Compare
75e3a87 to
f4aa26e
Compare
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your 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)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your 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-f65d554379b4753038c781bc4b5e889da1f34c0cAfterwards, run the upgrade commands from the latest release notes. |
f4aa26e to
b168406
Compare
b168406 to
f65d554
Compare
BeryJu
left a comment
There was a problem hiding this comment.
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
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.
blocking changes are from aug 11 and have since long been applied
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.
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.
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.
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.
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.
Details
Base of the password lockout stack:
What does this PR change?
A user's password hash and change date move from
Userto aPasswordDeviceowned 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()andset_unusable_password(). Each writes the device, then saves the user, so outgoing sync and cached policy results still see the change.user.passwordanduser.password_change_datestay readable, because property mappings (including the Google Workspace and Entra system blueprints) and Django's session hash use them. Django's own password writes onUsernow raise instead of silently doing nothing, socreate_user(),ak changepasswordand guardian's anonymous user go through the device or skip the password.The migration copies usable passwords to devices. The old
Usercolumns 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:
User actions, with the device's password change date:
Login after two and three wrong passwords:
Linked issues
None.
Checklist
make all)make docs)