Skip to content

Disallow protocol change via Registration Access Token - #51419

Merged
rmartinc merged 2 commits into
keycloak:mainfrom
msdaly200:51340
Aug 7, 2026
Merged

Disallow protocol change via Registration Access Token#51419
rmartinc merged 2 commits into
keycloak:mainfrom
msdaly200:51340

Conversation

@msdaly200

Copy link
Copy Markdown
Contributor

Closes #51340

Added check to in AbstractClientRegistrationProvider.update() that rejects any attempt to change a client's protocol field when the caller authenticates with a Registration Access Token, preventing an OIDC client from being silently converted to SAML via DCR.

Copilot AI balanced review requested due to automatic review settings August 4, 2026 10:22
@msdaly200
msdaly200 requested a review from a team as a code owner August 4, 2026 10:22
@msdaly200 msdaly200 changed the title 51340 Disallow protocol change via Registration Access Token Aug 4, 2026

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.

🟡 Not ready to approve

Unrelated username-validation and formatting changes should be split from the focused Registration Access Token security fix.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Prevents Registration Access Tokens from changing a client’s protocol, addressing #51340. The PR also contains unrelated username-validation changes.

Changes:

  • Rejects protocol changes authenticated by a Registration Access Token.
  • Adds RAT rejection and admin-token success tests.
  • Adds unrelated 255-character username validation and tests.
File summaries
File Description
tests/base/src/test/java/org/keycloak/tests/organization/authentication/OrganizationAuthenticationTest.java Tests organization username length validation.
tests/base/src/test/java/org/keycloak/tests/oid4vc/preauth/OID4VCredentialOfferPreAuthTest.java Removes whitespace.
tests/base/src/test/java/org/keycloak/tests/oauth/DirectGrantInputValidationTest.java Tests direct-grant username validation.
tests/base/src/test/java/org/keycloak/tests/forms/ResetPasswordTest.java Tests reset-password username length.
tests/base/src/test/java/org/keycloak/tests/forms/LoginTest.java Tests login username validation.
tests/base/src/test/java/org/keycloak/tests/client/ClientRegistrationTest.java Tests protocol-change authorization.
services/src/main/java/org/keycloak/services/validation/Validation.java Defines a username length limit.
services/src/main/java/org/keycloak/services/clientregistration/AbstractClientRegistrationProvider.java Rejects RAT-authenticated protocol changes.
services/src/main/java/org/keycloak/organization/authentication/authenticators/browser/OrganizationAuthenticator.java Enforces username length.
services/src/main/java/org/keycloak/authentication/authenticators/resetcred/ResetCredentialChooseUser.java Enforces username length during reset.
services/src/main/java/org/keycloak/authentication/authenticators/directgrant/ValidateUsername.java Validates and trims direct-grant usernames.
services/src/main/java/org/keycloak/authentication/authenticators/browser/AbstractUsernameFormAuthenticator.java Enforces username length during login.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI review requested due to automatic review settings August 4, 2026 10:32
Copilot AI previously approved these changes Aug 4, 2026

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.

🟢 Ready to approve

The authorization check is correctly scoped and covered by focused integration tests.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Copilot AI review requested due to automatic review settings August 4, 2026 12:37
Copilot AI dismissed their stale review, a newer Copilot review was requested August 4, 2026 12:40
Copilot AI previously approved these changes Aug 4, 2026

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.

🟢 Ready to approve

The authorization check is narrowly scoped, symmetric across protocols, and covered by appropriate integration tests.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@rmartinc rmartinc 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.

Thanks @msdaly200! LGTM!

Just a nickpick for the tests. If you prefer to maintain like it is now just let me know and I can merge as it is now. But I prefer to use the registerClient as it is used in all the rest of methods.

Comment thread tests/base/src/test/java/org/keycloak/tests/client/ClientRegistrationTest.java Outdated
Comment thread tests/base/src/test/java/org/keycloak/tests/client/ClientRegistrationTest.java Outdated
Comment thread tests/base/src/test/java/org/keycloak/tests/client/ClientRegistrationTest.java Outdated
Copilot AI review requested due to automatic review settings August 6, 2026 14:02
@msdaly200

Copy link
Copy Markdown
Contributor Author

thanks @rmartinc I've made those changes

Copilot AI dismissed their stale review, a newer Copilot review was requested August 6, 2026 14:05

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.

🟢 Ready to approve

The focused validation correctly closes the reported authorization gap and is covered by integration tests.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

…cess token

Signed-off-by: Marie Daly <marie.daly1@ibm.com>
…AT in DCR

Signed-off-by: Marie Daly <marie.daly1@ibm.com>
Copilot AI review requested due to automatic review settings August 7, 2026 08:19

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mabartos
mabartos requested a review from rmartinc August 7, 2026 09:44

@rmartinc rmartinc 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.

Thanks @msdaly200 for the PR and @mabartos for the review!

@rmartinc
rmartinc merged commit 4fcf214 into keycloak:main Aug 7, 2026
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DCR: Registration access token allows protocol switch from OIDC to SAML

4 participants