Skip to content

stages/password: lock password login after failed attempts - #24794

Merged
dominic-r merged 1 commit into
mainfrom
dominic/password-lockout
Nov 2, 2026
Merged

dominic-r merged 1 commit into
mainfrom
dominic/password-lockout

Conversation

@dominic-r

@dominic-r dominic-r commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Details

Part of the password lockout stack, on top of #24325. Screenshots of the whole stack are in #24325.

What does this PR change?

A Password stage, including one embedded in an Identification stage, can lock password login after Failed attempts before lockout consecutive failures. The default is 0, which disables lockout. A locked password is refused even when correct, including app passwords submitted to the stage. Existing sessions and passwordless authentication are unaffected. A successful login or a password change clears the count; a password change keeps the lock.

Administrators who can reset a user's password can lock and unlock it with POST /api/v3/authenticators/password/{id}/lock/ and /unlock/. The user API returns password_device and password_locked. Lock transitions create authenticator_locked and authenticator_unlocked events.

New locks, automatic or manual, need an Enterprise license. Without one, existing locks stay enforced and can still be unlocked. Service accounts are exempt, as are LDAP and Kerberos users whose password the selected backend checks against an enabled source. Optional last-attempt warning and lockout messages replace the generic error.

Why is this change needed?

Failed attempts only cancel the flow today, and the user can restart it right away. There is no built-in way to stop repeated guessing against one account.

How was this tested?

Tests cover the threshold, reset on success, license expiry, enforcement without the enterprise app, LDAP and Kerberos exemptions, service accounts, the password embedded in an Identification stage, concurrent failures, API permissions (global, per user and on yourself), and rollback when writing the audit event fails. Manually locked a user through the API and through failed logins on a dev instance.

Linked issues

None.


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

@dominic-r dominic-r self-assigned this Aug 5, 2026
@dominic-r dominic-r added area:frontend Features or issues related to the browser, TypeScript, Node.js, etc area:backend labels Aug 5, 2026
@dominic-r dominic-r added this to the Release 2026.11.0: Required milestone Aug 5, 2026
@dominic-r
dominic-r marked this pull request as ready for review August 5, 2026 23:36
@dominic-r
dominic-r requested a review from a team as a code owner August 5, 2026 23:36
Copilot AI lite review requested due to automatic review settings August 5, 2026 23:36
@dominic-r
dominic-r requested a review from a team as a code owner August 5, 2026 23:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@netlify

netlify Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit d96ac61
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a8f1e3b7562230008f82675
😎 Deploy Preview https://deploy-preview-24794--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.

@dominic-r dominic-r closed this Aug 5, 2026
@dominic-r
dominic-r deleted the dominic/password-lockout branch August 5, 2026 23:37
@github-project-automation github-project-automation Bot moved this from Todo to Done in authentik Core Aug 5, 2026
@dominic-r
dominic-r restored the dominic/password-lockout branch August 5, 2026 23:38
@dominic-r
dominic-r deleted the dominic/password-lockout branch August 5, 2026 23:38
@dominic-r
dominic-r restored the dominic/password-lockout branch August 5, 2026 23:42
@dominic-r dominic-r reopened this Aug 5, 2026
@github-project-automation github-project-automation Bot moved this from Done to Todo in authentik Core Aug 5, 2026
@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from 7bf6173 to 514d7a7 Compare August 5, 2026 23:42
Copilot AI review requested due to automatic review settings August 7, 2026 14:49
@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from 514d7a7 to 2aa36f8 Compare August 7, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.80769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.84%. Comparing base (b606382) to head (245d468).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
authentik/stages/password/lockout.py 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24794      +/-   ##
==========================================
+ Coverage   92.76%   92.84%   +0.08%     
==========================================
  Files        1205     1211       +6     
  Lines       82564    83335     +771     
  Branches     4686     4686              
==========================================
+ Hits        76587    77370     +783     
+ Misses       5901     5889      -12     
  Partials       76       76              
Flag Coverage Δ
conformance 30.73% <20.57%> (-0.12%) ⬇️
e2e 35.52% <22.88%> (-0.13%) ⬇️
integration 28.21% <17.11%> (-0.11%) ⬇️
rust 49.31% <ø> (ø)
unit 94.38% <99.80%> (+0.07%) ⬆️
unit-migrate 94.38% <99.80%> (+0.07%) ⬆️

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 Aug 7, 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-2aa36f807c312a82214c6931ed41ecb70dbd0803
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-2aa36f807c312a82214c6931ed41ecb70dbd0803

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

@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from 2aa36f8 to a8dfbeb Compare August 9, 2026 17:15
Comment thread authentik/stages/password/api.py Outdated
from rest_framework.viewsets import ModelViewSet

from authentik.core.api.used_by import UsedByMixin
from authentik.enterprise.license import LicenseKey

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't import enterprise from oss

@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from af46482 to da57f2b Compare September 27, 2026 21:31
@dominic-r
dominic-r force-pushed the dominic/password-lockout branch 2 times, most recently from 56f0829 to aab5059 Compare September 27, 2026 22:47
@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from 599ec98 to f41c1dd Compare October 4, 2026 19:44
Comment thread authentik/stages/password/lockout.py Resolved
Comment thread schema.yml Outdated
$ref: '#/components/responses/ValidationErrorResponse'
'403':
$ref: '#/components/responses/GenericErrorResponse'
/core/users/{id}/lock_password/:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider moving to /authenticators/password/{id}/lock_password/ or similar

Comment thread authentik/stages/password/lockout.py Outdated
from authentik.stages.password.models import PasswordDevice, PasswordStage

PLAN_CONTEXT_LOCKED_ATTEMPTS = "goauthentik.io/stages/password/locked_attempts"
SERVICE_ACCOUNT_TYPES = (UserTypes.SERVICE_ACCOUNT, UserTypes.INTERNAL_SERVICE_ACCOUNT)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move elsewhere or straight up remove

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to core, near the declaration of types

Comment thread authentik/stages/password/lockout.py Outdated
):
"""Enforce password locks, with optional licensed failure counting."""

def __init__(self, password_stage: PasswordStage, request: HttpRequest):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does nothing?

@@ -1,22 +1,44 @@
"""password tests"""

from concurrent.futures import ThreadPoolExecutor

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trim tests

Base automatically changed from dominic/password-device to main November 2, 2026 16:57
@dominic-r
dominic-r force-pushed the dominic/password-lockout branch from e21600b to 245d468 Compare November 2, 2026 17:02
@dominic-r
dominic-r enabled stacked auto-merge (squash) November 2, 2026 17:03
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Nov 2, 2026
@dominic-r
dominic-r merged commit 733d131 into main Nov 2, 2026
171 checks passed
@dominic-r
dominic-r deleted the dominic/password-lockout branch November 2, 2026 19:01
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend area:frontend Features or issues related to the browser, TypeScript, Node.js, etc

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants