Skip to content

web/flow: Continuous Login Locks - #25692

Closed
GirlBossRush wants to merge 5 commits into
mainfrom
continuous-login-locks
Closed

GirlBossRush wants to merge 5 commits into
mainfrom
continuous-login-locks

Conversation

@GirlBossRush

Copy link
Copy Markdown
Contributor

Details

This PR replaces the hand-rolled localStorage leader-election lock in the continuous-login tab orchestrator with the Web Locks API.

The previous localStorage approach is fairly consistent, but a few race-conditions given the right setup. Two tabs authenticating near-simultaneously could let both win the leadership role, letting them both attempt to drive the resume. The storage key could also become stale and needed a tab-liveness check (tabs.has(lockTabID)).

Now, calling navigator.locks.request(lockKey, { ifAvailable: true }, …) gives a single leader election, and the browser releases the lock automatically on navigation or tab close — removing both the race and the liveness heuristic.

Testing

Adds a Playwright e2e test (web/test/browser/999-continuous-login.test.ts) that drives two real tabs and asserts the follower resumes once the leader authenticates. The two tabs open on the identification stage, the leader authenticates, and the follower reaches /if/user/ on its own without credentials being entered in it.

@GirlBossRush
GirlBossRush requested a review from a team as a code owner September 3, 2026 02:08
@GirlBossRush
GirlBossRush requested a review from BeryJu September 3, 2026 02:08
@GirlBossRush GirlBossRush added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Sep 3, 2026
@GirlBossRush GirlBossRush self-assigned this Sep 3, 2026
@GirlBossRush GirlBossRush moved this from Todo to Needs review in authentik Core Sep 3, 2026
@netlify

netlify Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 0b5bf96
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6a98d8f2fee9cd00089642fc
😎 Deploy Preview https://deploy-preview-25692--authentik-storybook.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 Sep 3, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 6d2ba77
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a98d69132cc4d0008eed7a2
😎 Deploy Preview https://deploy-preview-25692--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 Sep 3, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 6d2ba77
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a98d6915ea2400008f57de6
😎 Deploy Preview https://deploy-preview-25692--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 Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.39%. Comparing base (980d4de) to head (05eac54).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25692      +/-   ##
==========================================
- Coverage   92.42%   92.39%   -0.04%     
==========================================
  Files        1192     1192              
  Lines       80539    80539              
  Branches     4351     4351              
==========================================
- Hits        74437    74411      -26     
- Misses       6036     6062      +26     
  Partials       66       66              
Flag Coverage Δ
conformance 32.28% <ø> (+<0.01%) ⬆️
e2e 36.95% <ø> (+<0.01%) ⬆️
integration 28.81% <ø> (-0.35%) ⬇️
rust 44.42% <ø> (ø)
unit 94.07% <ø> (+<0.01%) ⬆️
unit-migrate 94.07% <ø> (+<0.01%) ⬆️

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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Playwright e2e — ❌ Failed

Result Count
✅ Passed 43
❌ Failed 1
⚠️ Flaky 0
⏭️ Skipped 4

Workflow run · HTML report hosting is gated off until the authentik-playwright-artifacts S3 bucket is provisioned (vars.PLAYWRIGHT_S3_ENABLED). Until then, download the playwright-report artifact from the run page.

@GirlBossRush
GirlBossRush requested review from a team as code owners September 8, 2026 13:39
Base automatically changed from web/server-context to 21994-playwright-ci September 8, 2026 14:05
@GirlBossRush
GirlBossRush force-pushed the 21994-playwright-ci branch 10 times, most recently from fcaf365 to c73a0cb Compare September 10, 2026 14:19
Base automatically changed from 21994-playwright-ci to web/router-admin-flip September 10, 2026 14:26
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Playwright e2e

Download this run's HTML report and traces, then open the report:

gh run download 40516635235 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-report

GirlBossRush and others added 5 commits October 27, 2026 13:56
Replace the hand-rolled localStorage lock — a non-atomic check-then-set
guarded by a tab-liveness heuristic — with navigator.locks. `ifAvailable`
gives immediate leader election with no double-leader race, and the
browser releases the lock on navigation or close, so there is no stale
lock to reap and no manual cleanup.
Drive two real tabs in one browser context: authenticate in the leader
and assert the follower leaves the identification stage on its own. The
global flag is enabled in beforeAll and restored in afterAll; the file
carries the highest numeric prefix and runs serially so it does not race
the parallel login suite.
Move the global-flag toggle into an e2e/ helper (setInstanceFlag) so the
test stops hand-constructing fixtures inline, and confirm the settings
save through its success toast instead of matching the settings network
response — keeping the flow on the UI like the rest of the suite.
@GirlBossRush

Copy link
Copy Markdown
Contributor Author

Resolved in #26269

@github-project-automation github-project-automation Bot moved this from Needs review to Done in authentik Core Oct 27, 2026
@GirlBossRush
GirlBossRush deleted the continuous-login-locks branch October 27, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant