Repository navigation
Proposal to support both alias and id in rest endpoints
#42942
Replies: 6 comments 40 replies
|
We could consider in the future to support additional URN types, for example for users we could support: I'd be careful with this though. |
|
I think this is a reasonable compromise between idempotent PUT (I have a single endpoint to create or update a resource using a immutable identifier), and changeable aliases (like Client ID). I assume the "kcid" could be user defined, so that I can do Obvious downside is that we cannot have a Client ID starting with |
|
Just to summarize what've discussed on today's sync. We will use the approach outlined in this discussion:
|
8BD0
|
A related question to this discussion: should the UUID be user specifiable? I.e. could I do The main motivation for UUIDs is from my perspective the immutability. That means Do you see any issues with user specifiable UUIDs? Do we want to have some validations the provided UUID is actually a UUID? Isn't UUID rather an internal construct that Keycloak should have the control over (versions etc.)? CC @shawkins – related to our private discussion. |
|
Thinking about it more, I believe allowing to reference resources via UUID as a path parameter is not really something we should do in the end. The main reason is we cannot use UUIDs with PUT. That is because we do not want UUIDs to be user specifiable, hence we can't do something like Additionally, we can't allow changing the alias via PUT as that would break the idempotency:
I can see a couple of options:
In both cases, we'd support referencing by alias as a path param (e.g. For changing the alias, we could either:
To support changing aliases via declarative config resources, we could add a dedicated field just to the declarative representation (called something like newClientId) that would then be cleared when the alias is changed. |
|
Based on today's offline discussion, opened a related issue #46540. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In Admin v1 most of the times the UUID is used in the path (
/clients/<uuid>), but sometimes it uses the alias (/identity-provider/instances/{alias}`. The fact that UUIDs are not generated, and not even returned in the response means that after creating a resource you need to parse the location header to get the UUID if you want to make further changes to the resource.To make this easier the idea was to use the public ID/alias for example
/clients/clientIdwhen retrieving things. However, this could change, so the proposal here is to add support for either lookup by public ID or internal ID, but make it explicit with using anurn.For example both paths below refer to the same client:
This would allow choosing either convenience (alias) or non-changeable when using the Admin v2 APIs.
One question is if the returned object should use the
urnsyntax for the id or not.For example should
GET ../clients/urn:kcid:<uuid>return:{ "id": "<uuid>" }or{ "id": "urn:kcid<uuid>" }For completeness for different different resources uses different aliases, which would be the default used in the path unless
urn:kcidis used:/parent/child)myrole)All reactions