Repository navigation
Use policy iterations in Argon2 policyCheck - #55027
Merged
Merged
Conversation
Closes keycloak#53633 Co-authored-by: David Sere <dse@tuta.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This was referenced Nov 11, 2026
Closed
Closed
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change aligning Argon2 policy checks with hash-creation iteration rules.
No open issues 🎉
What changed in this PR
This PR aligns Argon2 policy checks with the iteration rules used when creating password hashes, preventing unnecessary re-hashing when a hash already matches the realm policy. The concurrent credential-overwrite issue remains separately tracked in #55028.
Changes:
- Share iteration selection between
policyCheckandencodedCredential, preserving the provider fallback for unset values or values above 100. - Add regression coverage for matching and changed policies, default iterations, and migration from PBKDF2.
- Move the existing Argon2 test into the new test framework, using credential-manager validation.
| File | Description |
|---|---|
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/PasswordHashingTest.java |
Remove the migrated Argon2 test and unused imports. |
tests/base/src/test/java/org/keycloak/tests/model/Argon2PasswordHashTest.java |
Cover Argon2 defaults, password validation, and policy-driven re-hashing. |
crypto/default/src/main/java/org/keycloak/crypto/hash/Argon2PasswordHashProvider.java |
Unify iteration selection for hashing and policy checks; clarify documentation. |
Review effort: Balanced
ahus1
marked this pull request as ready for review
November 11, 2026 12:57
8000
ahus1
enabled auto-merge (squash)
November 11, 2026 12:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #53633
First part of the split of #53742. The overwrite of a concurrently changed credential is tracked in #55028.
Decisions and assumptions
policyCheckfollowsencodedCredential, not the other way around, so the existing rule stays: policy iterations of 100 or less are used, anything above is assumed to be meant for PBKDF2 and ignored.testArgon2moved from the ArquillianPasswordHashingTestinto the same class, and validates the password through the credential manager instead of the login form, as the form is not specific to Argon2.Based on the work of @d53dave in #53742.