Repository navigation
web/flow: fix remember-me being cleared by CSRF token rotation - #25205
Merged
GirlBossRush merged 5 commits intoOct 20, 2026
Merged
Conversation
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook 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. |
Contributor
Author
|
Hello, there appears to be an approval to run the remaining CI workflows. |
GirlBossRush
force-pushed
the
fix/remember-me-csrf-rotation
branch
from
October 20, 2026 00:13
5756c9a to
941e419
Compare
Split #common/storage into an accessor and shared types, and require storage keys to use the ak: prefix via a PersistenceKey type. Values under the old remember-me and library view mode keys are moved to the new keys on load, so returning users keep their remembered username and layout. The migrations are marked for removal in 2027.2 (goauthentik#27036). Remove ShowHintController, which has had no users since goauthentik#21781.
The remembered username was keyed to a session ID derived from the CSRF token, and cleared whenever the two didn't match. Django rotates the CSRF token on every successful login, so the check failed on every later visit and the username was always forgotten. Drop the check, so the username is only cleared by switching the toggle off or following "Not you?", and discard the session ID left by earlier versions. Co-authored-by: Shawn O'Dell <[email protected]>
The remember-me input listener was only attached from the toggle's change handler, so a returning user, who arrives with the switch already checked, never had it bound. A different user on the same device could type and submit their own username without it ever reaching localStorage, leaving the previous username prefilled forever, and auto-submitted in identification-only flows. Track whether the feature is on, seeded from the persisted value, and reconcile the listener when the controller connects and after each update. The stage adds the controller after it has rendered, so a further update isn't guaranteed. Cancel a pending keystroke write when the listener is detached, so switching the toggle off can't be undone by a write queued in the same frame. Disconnect the controller before the stage removes it, since removeController doesn't notify it and the listener would otherwise keep recording after the server turns remember-me off. Co-authored-by: Shawn O'Dell <[email protected]>
canAutoSubmit only checked whether a username was remembered when the page loaded, so a returning user who switched the toggle off was kept from being auto-submitted only by the one-shot attempt counter. Also require the feature to still be on. Checking only the live toggle state would instead auto-submit first-time visitors as soon as they opted in.
GirlBossRush
force-pushed
the
fix/remember-me-csrf-rotation
branch
from
October 20, 2026 02:50
6659142 to
3ad3964
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25205 +/- ##
==========================================
- Coverage 92.36% 92.32% -0.04%
==========================================
Files 1188 1188
Lines 80005 80005
Branches 4351 4351
==========================================
- Hits 73893 73867 -26
- Misses 6046 6072 +26
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
The API answers before the worker has applied the default blueprints. Until then `/` redirects to an authentication flow that doesn't exist yet and 404s, so the availability check could fail on a slow start and skip the whole suite. Poll until the redirect chain resolves, and run the setup steps serially so the login step waits on it too.
GirlBossRush
approved these changes
Oct 20, 2026
2 tasks done
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
* main: (21 commits) policies: fix warning from setting non-string tracing data (#27062) root: annotate hot paths (#27052) website/docs: contributing: add guidelines for vendor contributions (#27032) providers/saml: Add ability to select encryption algorithm (#27009) lib: set postgres timezone on connection (#27053) core: add postgres connection info (#27024) ci: fix cargo deny for basic-toml (#27054) web/elements: keep ak-array-input edits through form submission (#27045) enterprise: optimize middleware (#27015) core: bump goauthentik/platform-ssh from 26.04-ak-0.72.0 to 26.04-ak-0.72.1 in /tests/e2e (#27038) core: bump ruff from 0.16.10 to 0.17.0 (#27044) core: bump sentry-sdk from 2.71.0 to 2.72.0 (#27043) core: bump django-postgres-extra from 3.0.0 to 3.0.1 (#27042) core: bump python-kadmin-rs from 0.7.4 to 0.7.5 (#27040) core: bump goauthentik/selenium from 152.0-ak-0.72.0 to 152.0-ak-0.72.1 in /tests/e2e (#27039) core: bump aiohttp from 3.14.3 to 3.14.4 (#27034) web/flow: fix remember-me being cleared by CSRF token rotation (#25205) web/theme: Remove the categories build from the theme (#26982) core: bump library/golang from `2f84bc9` to `4766793` in /lifecycle/container (#26996) providers/saml: verify logoutrequest/response signatures (#26534) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
The identification stage's "Remember me on this device" toggle never is cleared on login, the next visit the username is not prefilled and the toggle is unchecked.
RememberMeControllerderived a "session ID" from the first 8 characters of theauthentik_csrfcookie, stored it alongside the username, and deleted the stored username whenever the two no longer matched. Django rotates the CSRF token on login, so that value can never match on the user's next visit.Reproduction (no login required)
enable_remember_meon.localStorage.setItem("authentik-remember-me-user", "[email protected]"); localStorage.setItem("authentik-remember-me-session", "OLDTOKEN").authentik-remember-me-useris deleted, the field is empty, the toggle unchecked.Fix
The stored username is now cleared only by an explicit user action: switching the toggle off, or following the "Not you?" link, which already calls
RememberMeStorage.reset()fromFormStatic. The legacyauthentik-remember-me-sessionkey is deleted so state written by earlier versions is cleaned up.Adds
RememberMeController.unit.test.tscovering the behavior, including a regression case asserting the username survives a rotated CSRF cookie (fails onmain, passes here).Checklist
cd web && pnpm test)make lint-fix)