Repository navigation
Conversation
There was a problem hiding this comment.
Thank you @Praiztl for the PR! Correct fix.
The production code change is sound. The redirect URI passed in the query string is the same value already resolved and validated by resolveRedirectUri() at invitation-creation time. At registration time, AuthorizationEndpointChecker.checkRedirectUri() re-validates it against the client's redirect URIs via RedirectUtils.verifyRedirectUri(), so there's no open redirect risk. The StringUtil.isBlank guard is appropriate — resolveRedirectUri() throws for non-account clients if resolution fails, but the guard handles the account-client edge case cleanly.
Few nits:
- The fix always appends redirect_uri when it's non-blank, even for clients with a single redirect URI where the existing
getSingleValidRedirectUrifallback already works. This is harmless — the endpoint validates it either way — but it means existing registration links now carry a parameter they didn't before. Not a problem in practice; just noting it's a behavior change for the common case too. - The test registers cleanup for
INVITEE_EMAILusers, but it only opens the registration page without completing registration — so the user is never created. The cleanup is defensive and harmless, but it's slightly misleading. This is fine as-is; just calling it out. - the test verifies the link parameters and that the registration page loads, but doesn't complete registration. This is acceptable scope since
testRegistrationConsumesInvitationalready covers the full flow. However, completing registration in this test with a multi-redirect client would give stronger confidence that the redirect after registration also works correctly. Worth considering but not blocking.
Since the PR is still draft, I was wondering whether you still plan to make some changes to it, or whether it could be marked as ready for review.
There was a problem hiding this comment.
🟡 Changes recommended
The unvalidated client base URL can cause previously working registration invitations to fail with invalid_redirect_uri instead of preserving the valid single-URI fallback.
1 open issue
What changed in this PR
Addresses #55412 by including the resolved redirect URI in organization invitation registration links, allowing the registration endpoint to handle clients with multiple allowed redirect URIs.
Changes:
- Adds
redirect_urito registration links when the resolved value is nonblank. - Adds an integration test checking the link parameters and successful navigation to the registration page.
| File | Description |
|---|---|
| tests/base/src/test/java/org/keycloak/tests/organization/admin/OrganizationInvitationTokenTest.java | Tests invitation registration links for a client with multiple redirect URIs. |
| services/src/main/java/org/keycloak/organization/admin/resource/OrganizationInvitationResource.java | Appends the resolved redirect URI to new-user registration links. |
Review effort: Balanced
|
Thanks for the review, @vramik. Marked it ready. Happy to extend the test to complete registration with the multi-redirect client if you'd like that extra coverage, just let me know. |
|
The latest commit (07036ed) addresses Copilot's regression note. The resolved redirect URI is now validated with RedirectUtils.verifyRedirectUri before it is appended, so a client Home URL that is not a registered redirect URI is omitted and the existing single redirect URI fallback is kept. I added a regression test, testRegistrationLinkOmitsRedirectUriWhenClientBaseUrlIsNotARegisteredRedirectUri, for that case and confirmed the full OrganizationInvitationTokenTest class passes. |
There was a problem hiding this comment.
🟡 Changes recommended
Invitation redirect validation ignores the client option permitting OIDC response parameters, so invitations can still fail when multiple redirects are registered.
1 open issue
1 resolved since last review
Review effort: Balanced
| if (client != null && RedirectUtils.verifyRedirectUri(session, invitationTarget.redirectUri, client) != null) { | ||
| builder.queryParam(OAuth2Constants.REDIRECT_URI, invitationTarget.redirectUri); | ||
| } |
|
On the OIDC response parameter note: this is a deliberate scope decision. The 3-arg RedirectUtils.verifyRedirectUri uses the default forbidden-parameter set, which matches the registration endpoint's behaviour for the default configuration. The two only diverge when a client has the legacy isAllowOidcParamsInRedirectUris option enabled and its resolved redirect URI carries an OIDC response parameter, which is a narrow backward-compat case outside the multiple-redirect-URI scenario this issue targets. I would rather keep the fix minimal than replicate the full endpoint policy here, but I am happy to extend it if a maintainer prefers to close that gap too. |
533ebe7 to
fc3a417
Compare
| String validRedirectUri = client == null ? null | ||
| : RedirectUtils.verifyRedirectUri(session, invitationTarget.redirectUri, client); | ||
| if (validRedirectUri != null) { | ||
| builder.queryParam(OAuth2Constants.REDIRECT_URI, validRedirectUri); |
fc3a417 to
08495bd
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Invitation redirect validation ignores the global/per-client compatibility setting, rejecting valid registered URLs and leaving clients with multiple redirect URIs with broken invitation links.
2 open issues
Review effort: Balanced
Closes keycloak#55412 Signed-off-by: Tochukwu Chikezie <95018735+Praiztl@users.noreply.github.com>
…on invite link Signed-off-by: Tochukwu Chikezie <95018735+Praiztl@users.noreply.github.com>
Signed-off-by: Tochukwu Chikezie <95018735+Praiztl@users.noreply.github.com>
08495bd to
d913edc
Compare
|
@vramik thanks for the review. Your approval is in, and the only thing left is the CI run, which is currently waiting on a maintainer to approve the workflow. Could you approve the run when you get a chance so this can merge? Happy to rebase or address anything else if needed. |
|
@Praiztl thank you! As you pointed out, CI is waiting for a maintainer and I am not one of them, @pedroigor will trigger it once he gets to it. |

Closes #55412
Decisions and assumptions:
invitationTarget.redirectUri, which is already resolved and validated against the client and is the same value stored in the token'sreduri, so no new validation is added.redirect_uriis only appended when it is non-blank, so the link stays the same for clients that resolve no redirect URI.This change was prepared with the help of an AI agent (Claude Code).