8000 [client-v2] Require 'clientId' in the payload by mabartos · Pull Request #47533 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

[client-v2] Require 'clientId' in the payload - #47533

Merged
vmuzikar merged 4 commits into
keycloak:mainfrom
mabartos:KC-47524
Apr 7, 2026
Merged

vmuzikar merged 4 commits into
keycloak:mainfrom
mabartos:KC-47524

Conversation

@mabartos
@mabartos mabartos commented Mar 27, 2026 •
Copy link
Copy Markdown
Member

@mabartos
mabartos requested review from a team as code owners March 27, 2026 16:06
@mabartos mabartos self-assigned this Mar 27, 2026
@mabartos
mabartos force-pushed the KC-47524 branch 2 times, most recently from 532aebb to d2b3579 Compare March 30, 2026 09:53
@mabartos
mabartos requested a review from a team as a code owner March 30, 2026 09:53
@michalvavrik
Copy link
Copy Markdown
Member

While I didn't know about #47574, I already handled it in my PR opened before this one. Let's go with your version as you have linked actual opened issue.

@mabartos
Copy link
Copy Markdown
Member Author

@michalvavrik Ahh, didn't know about that. Whatever you prefer.

@michalvavrik michalvavrik left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the CLI portion is fine (I handled it by simply detecting the violations, but making it explicit is better for backwards compatibility), thanks for fixing it.

As for #47524 (requiring clientId) I think this is architectural decision. It is bit suprising for the PUT as then you have it twice (in path and in the object). I remember that we used to use different DTO for PUT when I used to write CRUD microservices, which would avoid this problem, but that is just a preference.

However, it is aligned with what Steven keeps repeating (that PUT should require the full resource). I'll leave decision on that part to other reviewers.

@sschu
sschu commented Mar 30, 2026
Copy link
Copy Markdown
Contributor

@mabartos As discussed today during the WG meeting, can you please also make protocol required?

@mabartos
Copy link
Copy Markdown
Member Author

@sschu Makes sense. Added.

@mabartos
mabartos requested review from michalvavrik and sschu March 30, 2026 12:31
Closes keycloak#47524

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Closes keycloak#47579

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Closes keycloak#47574

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
@sschu sschu 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.

LGTM!

Comment on lines +170 to +183
var request = switch (getHttpMethod()) {
case HttpPost.METHOD_NAME -> {
var r = new HttpPost(getClientsApiUrl());
r.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
yield r;
}
case HttpPut.METHOD_NAME -> {
var r = new HttpPut(getClientApiUrl("%20"));
r.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
yield r;
}
default -> throw new IllegalStateException("Unexpected value: " + getHttpMethod());
};
setAuthHeader(request);
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.

Why not to use getRequest?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vmuzikar For the POST it is doable, but not for PUT, as we check this special case as having the '%20' as clientId in the path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vmuzikar Updated for the POST: 33a85bb

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
8BD0
@vmuzikar vmuzikar 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.

LGTM, thanks.

@vmuzikar
vmuzikar merged commit 0b2ce29 into keycloak:main Apr 7, 2026
85 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
* Require clientId in the payload

Closes keycloak#47524

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

* Require 'protocol' field to be specified

Closes keycloak#47579

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

* Client API v2 CLI Client: Jakarta validation errors are not handled

Closes keycloak#47574

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

* Use getRequest() for POST in test

Signed-off-by: Martin Bartoš <mabartos@redhat.com>

---------

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
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.

Require 'protocol' field in the payload Client API v2 CLI Client: Jakarta validation errors are not handled Require 'clientId' field in the payload

4 participants

0