Repository navigation
Fix client secret length to always use HS512 entropy #49793 - #50083
Merged
Merged
Conversation
MdTanwer
force-pushed
the
fix/49793-client-secret-entropy
branch
from
June 18, 2026 04:43
46fe396 to
1d24c17
Compare
MdTanwer
marked this pull request as ready for review
June 18, 2026 04:55
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Keycloak’s client secret generation to always use HS512-level entropy (86 alphanumeric characters), ensuring sufficient strength for any HMAC-based signing configuration (including ID Token, UserInfo, Request Object, Access Token, and JARM), not just token endpoint auth signing.
Changes:
- Make
KeycloakModelUtils.generateSecret()always generate secrets with HS512-equivalent entropy via a newgetRequiredClientSecretLength()helper. - Keep
getSecretLengthByAuthenticationType(...)for compatibility while delegating to the fixed HS512-level length. - Update and extend test coverage to expect 86-character secrets, including regeneration for
client_secret_basicwith ID Token HS512 configured.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
server-spi-private/src/main/java/org/keycloak/models/utils/KeycloakModelUtils.java |
Forces client secret generation to use fixed HS512-level entropy and centralizes length computation in getRequiredClientSecretLength(). |
server-spi-private/src/test/java/org/keycloak/models/utils/KeycloakModelUtilsTest.java |
Adds unit tests for the new fixed required secret length and the compatibility behavior of getSecretLengthByAuthenticationType(...). |
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/ClientAuthSecretSignedJWTTest.java |
Updates expectations to HS512-level secret length and adds an integration test covering regeneration for client_secret_basic with ID Token HS512. |
MdTanwer
force-pushed
the
fix/49793-client-secret-entropy
branch
from
June 20, 2026 03:38
1d24c17 to
6d2c56a
Compare
Always generate 86-character secrets on create/regenerate to cover all HMAC signature use cases regardless of configured algorithms. Signed-off-by: MdTanwer <tanw9004167@gmail.com>
MdTanwer
force-pushed
the
fix/49793-client-secret-entropy
branch
from
June 23, 2026 08:24
6d2c56a to
f2f638b
Compare
Contributor
Author
|
Hey @mposolda there was an formating issue i have fixed that now I thisnk all checkout should pass |
mposolda
approved these changes
Jun 23, 2026
sashyo
pushed a commit
to tide-foundation/keycloak-IGA
that referenced
this pull request
Jul 20, 2026
…eycloak#50083) Fixes keycloak#49793 Signed-off-by: MdTanwer <tanw9004167@gmail.com>
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.
Summary
Fixes #49793
When regenerating a client secret, Keycloak previously derived secret length only from the Token Endpoint Authentication Signing Algorithm (via PR #39637). Other HMAC-based settings were ignored:
A client using
client_secret_basicwith ID Token Signature Algorithm = HS512 could receive a ~32-character secret insufficient for HS512.This change follows Marek's suggestion: always generate secrets at HS512-level entropy (86 alphanumeric characters) on create and regenerate, regardless of authentication type or configured signing algorithms.
Changes
KeycloakModelUtils.generateSecret()now usesgetRequiredClientSecretLength()(86 chars / ~512 bits)-
getSecretLengthByAuthenticationType()is kept for backwards compatibility but delegates to the same fixed lengthKeycloakModelUtilsTestClientAuthSecretSignedJWTTestto expect 86-character secrets and added coverage for regenerating with ID Token HS512 configured