Skip to content

web: Fix duplicate Turnstile widgets after extended idle (cherry-pick #21380 to version-2025.12) - #21472

Merged
BeryJu merged 6 commits into
version-2025.12from
cherry-pick/21380-to-version-2025.12
Apr 27, 2026
Merged

BeryJu merged 6 commits into
version-2025.12from
cherry-pick/21380-to-version-2025.12

Conversation

@authentik-automation

@authentik-automation authentik-automation Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Details

This PR back ports #21380 and the prerequisite #19757 into version 2025.12. A third commit aligns two lingering cosmetic drifts.

Commits

# SHA Origin Purpose
1 3a1d99bb #19757 squash merge Prerequisite — captcha refactor that introduces controllers/
2 9e663132 #21380 squash merge The actual fix — explicit Turnstile render
3 9ccaad0c new Aligns captcha files to main (see "Drift alignment" below)

Commit 1: Prerequisite

controllers/turnstile.ts doesn't exist on version-2025.12 — it's created by #19757, which extracted captcha provider logic into a controllers/ directory with a shared CaptchaController base. Without #19757, the fix has nothing to modify.

The prerequisite commit is the squash merge from main applied as-is. Groups of files:

Captcha refactor (the point of #19757)

  • web/src/flow/stages/captcha/CaptchaStage.ts — migrated to CaptchaHandlerHost / #refreshControllers() pattern
  • web/src/flow/stages/captcha/CaptchaStage.css — styles extracted from inline
  • web/src/flow/stages/captcha/shared.ts — iframe template extracted
  • controllers/CaptchaController.ts, controllers/grecaptcha.ts, controllers/hcaptcha.ts, controllers/turnstile.ts, controllers/shared.ts — new per-provider controllers
  • Deletes the old grecaptcha.ts, hcaptcha.ts, turnstile.ts files (moved into controllers/)

Captcha Storybook stories (also from #19757)

  • stories/grecaptcha.stories.ts, stories/hcaptcha.stories.ts, stories/turnstile.stories.ts — added
  • CaptchaStage.stories.ts — deleted (replaced by the per-provider stories)

Storybook / bundler plumbing needed by those new stories

  • .storybook/main.js, .storybook/preview.js — config updates
  • bundler/utils/node.js, types/esbuild.d.ts — asset import shims
  • package.json, package-lock.json — Storybook dep bumps
  • styles/authentik/storybook.css, stories/flow-interface.ts — shared story shell

Touched-by-refactor (non-captcha) — these are the spill-over from the refactor that happened to co-land in #19757. None change runtime behavior outside what #19757 already validated on main:

  • common/api/middleware.ts, common/theme.ts, common/types.ts, common/ui/locale/* — locale/theme plumbing used by the new story shell
  • elements/controllers/LocaleContextController.ts, elements/mixins/locale.ts, elements/messages/MessageContainer.ts
  • flow/FlowExecutor.ts, flow/FlowExecutor.stories.ts, flow/components/ak-flow-card.ts, flow/components/types.ts (new)
  • Sibling *Stage.stories.ts files — updated to match the new story shell

Commit 2: Backport

Turnstile's client-side script periodically self-upgrades, re-scans the DOM for .cf-turnstile elements, and renders duplicate widgets over time. This PR switches from implicit rendering to explicit rendering (?render=explicit + manual turnstile.render()) so the self-upgrade cycle no longer triggers a DOM scan.

Three files, all in web/src/flow/stages/captcha/:

  • CaptchaStage.ts — 1 line
  • controllers/turnstile.ts — 30/-14
  • shared.ts — 10/-2

Commit 3: Drift alignment

Two tiny cosmetic drifts:

File Addition Origin on main
CaptchaStage.css ak-stage-captcha.style-scope selector variants (4 lines) #20134
CaptchaStage.ts export default CaptchaStage; (1 line) #20397

Both are functionally inert on version-2025.12 — no code applies the style-scope class to ak-stage-captcha, and no importer uses the default export — but including them means the captcha tree in this PR is byte-for-byte identical to main. Full #20134 (+460/-229, 18 files, layout refactor) and #20397 (+58, 28 files, every flow stage) were deemed out-of-scope for a release-branch hotfix.

Verified with git diff main..HEAD -- web/src/flow/stages/captcha/ → empty.

Test plan

  • npm run lint:types — no new type errors vs version-2025.12 baseline (verified locally: 26 → 23, the 3 differences are captcha story errors that the refactor fixes)
  • Storybook boots and renders captcha stages (npm run storybook)
  • Manual: trigger a Turnstile CAPTCHA flow and idle for >5 min; confirm no duplicate widgets accumulate
  • Manual: hCaptcha and reCAPTCHA flows still render/submit correctly (regression check on the refactor)

@netlify

netlify Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 3efe8a7
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/69ef74b6fe9ea900081f5205
😎 Deploy Preview https://deploy-preview-21472--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.

@netlify

netlify Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 3efe8a7
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/69ef74b69ca79d000839fb05
😎 Deploy Preview https://deploy-preview-21472--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.

@codecov

codecov Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.31%. Comparing base (946977f) to head (0449366).
⚠️ Report is 1 commits behind head on version-2025.12.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@               Coverage Diff                @@
##           version-2025.12   #21472   +/-   ##
================================================
  Coverage            93.31%   93.31%           
================================================
  Files                  947      947           
  Lines                52936    52936           
================================================
+ Hits                 49397    49399    +2     
+ Misses                3539     3537    -2     
Flag Coverage Δ
e2e 44.12% <ø> (-0.02%) ⬇️
integration 23.37% <ø> (+<0.01%) ⬆️
unit 91.66% <ø> (+<0.01%) ⬆️

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

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

@GirlBossRush
GirlBossRush force-pushed the cherry-pick/21380-to-version-2025.12 branch 2 times, most recently from 9ccaad0 to 616012e Compare April 17, 2026 04:24
@GirlBossRush
GirlBossRush requested a review from BeryJu April 17, 2026 04:28
@github-actions

github-actions Bot commented Apr 17, 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-0449366be48e7239a53802f7ae6731f612678ac4
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-0449366be48e7239a53802f7ae6731f612678ac4

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

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Apr 21, 2026
@GirlBossRush
GirlBossRush force-pushed the cherry-pick/21380-to-version-2025.12 branch 2 times, most recently from dad9215 to 6523a8e Compare April 22, 2026 15:37
@BeryJu

BeryJu commented Apr 23, 2026

Copy link
Copy Markdown
Member

depends on #21788 to fix the CI

GirlBossRush and others added 6 commits April 27, 2026 19:02
* Move inline styles into separate file.

* Fix preferred order of captcha vendor discovery.

* Clean up mutation and resize observer lifecycle.

* Flesh out controllers.

* Tidy refresh.

* Fix incompatibilities with Storybook.

* Flesh out captcha stories.

* Bump package.

* Flesh out stories.

* Move inline styles into separate file.

* Fix preferred order of captcha vendor discovery.

* Clean up mutation and resize observer lifecycle.

* Flesh out controllers.

* Tidy refresh.

* Remove unused.

* Bump package.

(cherry picked from commit 388f426)
* Flesh out turnstile fixes.

* format

Signed-off-by: Jens Langhammer <[email protected]>

---------

Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Jens Langhammer <[email protected]>
(cherry picked from commit 59ac8ba)
Picks up the non-PR-#21380 changes to captcha files that are already on
main: `.style-scope` selector variants in CaptchaStage.css (from #20134)
and `export default CaptchaStage` (from #20397). Both are functionally
inert on this branch — no code applies the style-scope class to
ak-stage-captcha, and no importer uses the default export — but
including them keeps the cherry-pick zero-drift against main.
@GirlBossRush
GirlBossRush force-pushed the cherry-pick/21380-to-version-2025.12 branch from bdb8465 to 0449366 Compare April 27, 2026 17:03
@BeryJu
BeryJu merged commit 5fa2c3b into version-2025.12 Apr 27, 2026
73 of 83 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Apr 27, 2026
@BeryJu
BeryJu deleted the cherry-pick/21380-to-version-2025.12 branch April 27, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants