Skip to content

stages/authenticator_validate: enforce code device restrictions - #26779

Merged
BeryJu merged 9 commits into
goauthentik:mainfrom
jsachs:fix/authenticator-code-device-restrictions
Oct 14, 2026
Merged

BeryJu merged 9 commits into
goauthentik:mainfrom
jsachs:fix/authenticator-code-device-restrictions

Conversation

@jsachs

@jsachs jsachs commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Authenticator validation stages filtered device classes when generating challenges, but code validation still tried every enrolled device. This allowed a valid TOTP code to satisfy an email-only stage despite TOTP being explicitly excluded.

We now restrict code verification to devices permitted by both the stage configuration and its issued challenges:

  • Enforce allowed device classes before verifying tokens.
  • Require email and SMS codes to match the challenged device.
  • Preserve class-wide validation for TOTP and static devices, so users can submit either allowed code type without selecting a specific device.
  • Avoid consuming tokens or updating throttling state for ineligible devices.

Add regression coverage for device restrictions and an end-to-end flow test confirming that an email-only stage rejects a valid TOTP code and subsequently accepts the email code.

Closes #26753

@netlify

netlify Bot commented Oct 8, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit ced13bc
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ac7805645e4f000087a8eba
😎 Deploy Preview https://deploy-preview-26779--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 Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.15966% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.21%. Comparing base (7a98195) to head (7d86476).

Files with missing lines Patch % Lines
...thentik/stages/authenticator_validate/challenge.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26779      +/-   ##
==========================================
+ Coverage   91.90%   92.21%   +0.31%     
==========================================
  Files        1181     1182       +1     
  Lines       78945    79056     +111     
  Branches     4351     4351              
==========================================
+ Hits        72551    72903     +352     
+ Misses       6328     6087     -241     
  Partials       66       66              
Flag Coverage Δ
conformance 32.58% <0.84%> (-0.05%) ⬇️
e2e 37.33% <9.24%> (+2.75%) ⬆️
integration 28.94% <0.84%> (-0.54%) ⬇️
rust 44.42% <ø> (ø)
unit 93.91% <99.15%> (+0.01%) ⬆️
unit-migrate 93.91% <99.15%> (+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.

@jsachs
jsachs marked this pull request as ready for review October 8, 2026 12:01
@jsachs
jsachs requested a review from a team as a code owner October 8, 2026 12:01
@BeryJu
BeryJu merged commit d09e057 into goauthentik:main Oct 14, 2026
140 checks passed
@jsachs
jsachs deleted the fix/authenticator-code-device-restrictions branch October 15, 2026 13:14
kensternberg-authentik added a commit that referenced this pull request Oct 15, 2026
* main: (86 commits)
  ci: switch version bump to action, like platform repo (#26949)
  core, web: update translations (#26940)
  ci: bump actions/create-github-app-token from 3.2.0 to 3.3.0 (#26946)
  ci: bump taiki-e/install-action from 2.87.27 to 2.87.28 in /.github/actions/setup (#26947)
  core: bump hyper-unix-socket from 0.6.1 to 0.7.0 (#26945)
  core: bump goauthentik/selenium from 152.0-ak-0.71.0 to 152.0-ak-0.72.0 in /tests/e2e (#26943)
  core: bump goauthentik/platform-ssh from 26.04-ak-0.71.0 to 26.04-ak-0.72.0 in /tests/e2e (#26944)
  core: keep the current login when adding a user after a stale session save (#26765)
  flows: fix blip of un-templated flow title placeholder (#26905)
  website/docs: Version 2026.8.4 Release Notes (cherry-pick #26934 to main) (#26939)
  core: bump rust-toolchain from 1.98.1 to 1.99.0 (#26634)
  stages/authenticator_validate: enforce code device restrictions (#26779)
  website/docs: Expand docs on aws installation (#26812)
  web: Add alert when JavaScript is disabled. (#26921)
  website: remove the docs glossary (#26930)
  core: bump axllent/mailpit from v1.31.4 to v1.31.5 in /tests/e2e (#26907)
  core: bump astral-sh/uv from 0.13.0 to 0.13.1 in /lifecycle/container (#26909)
  core: bump serde_json from 1.0.151 to 1.0.154 (#26911)
  core: bump the types group with 2 updates (#26912)
  core: bump aws-lc-rs from 1.18.1 to 1.18.2 (#26913)
  ...
kensternberg-authentik added a commit that referenced this pull request Oct 19, 2026
* main: (144 commits)
  ci: switch version bump to action, like platform repo (#26949)
  core, web: update translations (#26940)
  ci: bump actions/create-github-app-token from 3.2.0 to 3.3.0 (#26946)
  ci: bump taiki-e/install-action from 2.87.27 to 2.87.28 in /.github/actions/setup (#26947)
  core: bump hyper-unix-socket from 0.6.1 to 0.7.0 (#26945)
  core: bump goauthentik/selenium from 152.0-ak-0.71.0 to 152.0-ak-0.72.0 in /tests/e2e (#26943)
  core: bump goauthentik/platform-ssh from 26.04-ak-0.71.0 to 26.04-ak-0.72.0 in /tests/e2e (#26944)
  core: keep the current login when adding a user after a stale session save (#26765)
  flows: fix blip of un-templated flow title placeholder (#26905)
  website/docs: Version 2026.8.4 Release Notes (cherry-pick #26934 to main) (#26939)
  core: bump rust-toolchain from 1.98.1 to 1.99.0 (#26634)
  stages/authenticator_validate: enforce code device restrictions (#26779)
  website/docs: Expand docs on aws installation (#26812)
  web: Add alert when JavaScript is disabled. (#26921)
  website: remove the docs glossary (#26930)
  core: bump axllent/mailpit from v1.31.4 to v1.31.5 in /tests/e2e (#26907)
  core: bump astral-sh/uv from 0.13.0 to 0.13.1 in /lifecycle/container (#26909)
  core: bump serde_json from 1.0.151 to 1.0.154 (#26911)
  core: bump the types group with 2 updates (#26912)
  core: bump aws-lc-rs from 1.18.1 to 1.18.2 (#26913)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authenticator Validation Stage restricted to email accepts TOTP code from disallowed device class

2 participants