Repository navigation
stages/password: lock password login after failed attempts - #24794
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
7bf6173 to
514d7a7
Compare
514d7a7 to
2aa36f8
Compare
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your 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)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your 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-2aa36f807c312a82214c6931ed41ecb70dbd0803Afterwards, run the upgrade commands from the latest release notes. |
2aa36f8 to
a8dfbeb
Compare
| from rest_framework.viewsets import ModelViewSet | ||
|
|
||
| from authentik.core.api.used_by import UsedByMixin | ||
| from authentik.enterprise.license import LicenseKey |
There was a problem hiding this comment.
can't import enterprise from oss
af46482 to
da57f2b
Compare
56f0829 to
aab5059
Compare
599ec98 to
f41c1dd
Compare
| $ref: '#/components/responses/ValidationErrorResponse' | ||
| '403': | ||
| $ref: '#/components/responses/GenericErrorResponse' | ||
| /core/users/{id}/lock_password/: |
There was a problem hiding this comment.
consider moving to /authenticators/password/{id}/lock_password/ or similar
| 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) |
There was a problem hiding this comment.
move elsewhere or straight up remove
There was a problem hiding this comment.
move to core, near the declaration of types
| ): | ||
| """Enforce password locks, with optional licensed failure counting.""" | ||
|
|
||
| def __init__(self, password_stage: PasswordStage, request: HttpRequest): |
| @@ -1,22 +1,44 @@ | |||
| """password tests""" | |||
|
|
|||
| from concurrent.futures import ThreadPoolExecutor | |||
6b9b68e to
3da6a27
Compare
e21600b to
245d468
Compare
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 returnspassword_deviceandpassword_locked. Lock transitions createauthenticator_lockedandauthenticator_unlockedevents.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
make all)make docs)