What is not working well with the current Admin APIs? #37655
Replies: 16 comments 15 replies
-
|
Here's my list:
Now connecting this a bit to other things like Other things that are relevant is for example there are separate projects on how to declaratively configure KC, that basically wraps our endpoints in different APIs just to achieve better usability. In the new test framework we're also seeing a lot of the above issues, where it can be pretty hard to use the Java Admin client and know how to configure specific things again protocol mappers is a good example of something that is rather hard. Other issues seen are for example the ID returned in the location header; the fact that you have to use IDs returned by the server rather than things you defined yourself to lookup resources later; and last, but not least the issue with POST vs PUT and not nothing have that behaves, and having to try out if after defining a resource and creating or updating it if everything was actually updates as expected or not, or if you have to turn to separate calls for some bits. |
Beta Was this translation helpful? Give feedback.
-
|
Some additional thoughts from the perspective of declarative config (some were already touched above):
|
Beta Was this translation helpful? Give feedback.
-
|
Adding something that came up today as an issue. In Admin V1 it's often not possible to set a value back to We use PUT as a PATCH; PUT should really be make it like this, while PATCH is change these things. Further, we don't know if As an example on how I envision a PATCH working properly: The above should set the displayName to Not sure if Jackson/RestEasy has some mechanism so we could find out if a |
Beta Was this translation helpful? Give feedback.
-
|
Inconsistency in naming of classes and methods ADMIN REST interface for test usage: Keycloak ADMIN API: Small example - update user: |
Beta Was this translation helpful? Give feedback.
-
|
Maybe it's related to the implementation of the API rather than its interface, yet I'll add this: we face performance problems when we load users from Keycloak via pagination in case the User federation (with LDAP) is enabled |
Beta Was this translation helpful? Give feedback.
-
|
There are different return values for the Admin client for testing:
Unhandled Responses are causing concurrent failures in the ConcurrencyTest when calling REST API -> deadlocks. |
Beta Was this translation helpful? Give feedback.
-
|
Not directly related to the proposed refactoring but I just filed #39281 . Perhaps during the refactoring, you can extend test coverage to ensure that various combinations of parameters are exercised together to ensure there are no edge cases that are accidentally unsupported? |
Beta Was this translation helpful? Give feedback.
-
|
The documentation. For example, I am trying to data for a given client (to manually generate XML/PEM files, since there's no way via the REST api to download them, as you can within the web API), and this requires that you know what the id of the client is. Nowhere in the API documention does it mention that you can just do a GET on /admin/realm/realmname/clients/ and get a full list. Nor does it say that you can search for a client by name by hitting /auth/admin/realms/$REALM_NAME/clients?clientId=$CLIENT_ID Nowhere in the documentation does it say how to do things using the admin API such as "create a new SAML client". The description for creating a client only mentions that you need to set a ClientRepresentation, and goes into no detail about what the mysterious "Attributes" block is. There are no examples of how to make your initial request -- how to acquire an auth token and use it in subsequent requests with (for example) wget or LWP or curl and jq. Maybe these are things that someone who has written a rest client has worked with before, maybe they aren't. There could certainly be, at least, pointers to better resources for using REST in general. I've asked on the forumsif it's possible via the rest api to import a client using a saml sp-metadata.xml file, but with no responses. |
Beta Was this translation helpful? Give feedback.
-
|
Having null (and also not set) meaning that a default value is used is
fine.... as long as the GET operation of the resource does preserve this
and also returns null. Only internally the default should be applied. (An
additional read-only resource could provide the defaults, to show them in
configuration UIs like the admin console).
Using "default" as value resources end up with all properties required:
{
a: "default",
b: "default",
someKeyWithoutDefault: "foo",
d: "default"
}
It would be nicer to allow PUT:
{
someKeyWithoutDefault: "foo"
}
GET of this resource must return the same or at least
{
a: null,
b: null,
someKeyWithoutDefault: "foo"
d: null
}
consooo ***@***.***> schrieb am Mi., 21. Mai 2025, 09:50:
… Having empty strings or null values as defaults is generally problematic.
When using terraform for instance, lots of variables for clients are set
via map. Terraform goes into an infinite reconciliation loop when setting
keys with empty values, and not setting these keys will not set the values
to default.
Is it feasable to have some constant like "DEFAULT" set instead of empty
strings to make management via terraform and crossplane simpler?
—
Reply to this email directly, view it on GitHub
<#37655 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGAX6GADJDCTG2H3753IOL27QV33AVCNFSM6AAAAABX4U4DMWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMRRGY3DOMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
|
One limitation in the current Admin APIs is the lack of efficient ways to fetch hierarchical and related data. For example, retrieving all users within a group subtree along with their role and group mappings currently requires:
With n being the number of users, the total number of HTTP requests is O(n) (specifically 2n + 1), which becomes a performance and scalability bottleneck in larger realms. Possible solutionConsider introducing API endpoints that support embedding related entities or batch-fetching group- and role-mappings in bulk. This would drastically reduce the number of requests and make the API far more usable for automation and integration. Appreciate the effort going into the new API design. Really looking forward to a more efficient and developer-friendly Admin API v2! |
Beta Was this translation helpful? Give feedback.
-
|
Pagination is an issue. The Skip/Take approach is not performant, for a start, but the bigger problem is that when paging through all users, there is a very real possibility that a new user registers before I'm finished. Since the results are ordered by user Id, and the user Ids are not sequential, that user (and probably one other) can be skipped, and there isn't really any good way to even detect that this has happened. Even if I compare the number of users before and after to detect that there is a new user, I have no good option to deal with this apart from just starting again. |
Beta Was this translation helpful? Give feedback.
-
|
Why is the API and the export-import function drifting in different ways. E.g. why can n`t I export users in the frontend? In partial export there are no users. This makes moving or scaling to a new environment so difficult. Or to make a bulk import for example of a csv file. I know I can do many things in the API but as @schuerg already mentions relations are difficult or even not there. - like groups and user mappings. Please focus more on UX. It is easier to loose users or customer then getting them. Not all are great Java developers. Explaining everything in a forum shows exactly the problem! This should not be necessary! |
Beta Was this translation helpful? Give feedback.
-
Error description if token sent incorrectlyClient developers should be supported to find bugs in their authorization header with a helpful error description. The Admin API endpoints should provide details in case of a 401 Unauthorized response. I often observe this response when a client script is developed.
See #41673 |
Beta Was this translation helpful? Give feedback.
-
|
How to let a user choose which organization to authenticate into when using Direct Access (Direct Grant / Resource Owner Password Credentials) if the user is assigned to multiple organizations? |
Beta Was this translation helpful? Give feedback.
-
|
It would be great to have APIs for permissions in the REST API. I found a lot now collecting them from different blogs and so on, but that I would prefer to find in your REST API. E.g. It would be great to have in groups an additional tab for permission like for roles. I created that in my own extensions for keycloak. The problem is with the API you can just add a group to permissions inside the client authorization, but first after you clicked save, because the endpoint needs the complete PermissionRepresentation. In reality it just adds the groupId in the policy_config table. What I mean fine grained permission are needed more and more and you did a lot great stuff in keycloak, but sometimes UX could be easier, but the API does n't give you the possibility. |
Beta Was this translation helpful? Give feedback.
-
|
Just a short input from me: I'd like an api where I can delete multiple keycloak users at once. Currently we desire to remove approx 1 million user accounts, and we will definietely not want to do that with the current API (one at a time). Alternatively, we risk data corruption if we forget to clean up in one of the related tables if we decide to clean up directly in database. The complexity of deleting a user is best when abstracted away from internal details. My best alternative (for now) is a sql query looking something like this: -- delete all users from broker realm
WITH target_users AS (
SELECT user_entity.id as user_id
FROM user_entity
JOIN realm ON realm.id = user_entity.realm_id
WHERE realm."name" in ('broker')
-- AND id = '123' -- or use IN (...) for multiple users
-- limit 1
),
del_kc_ref AS (
UPDATE aktoerer SET keycloak_user_id = null
WHERE keycloak_user_id IN (SELECT user_id FROM target_users)
),
del_fed AS (
DELETE FROM federated_identity
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_attr AS (
DELETE FROM user_attribute
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_action AS (
DELETE FROM user_required_action
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_role AS (
DELETE FROM user_role_mapping
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_consent AS (
DELETE FROM user_consent
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_cred AS (
DELETE FROM credential
WHERE user_id IN (SELECT user_id FROM target_users)
),
del_group AS (
DELETE FROM user_group_membership
WHERE user_id IN (SELECT user_id FROM target_users)
)
DELETE FROM user_entity
WHERE id IN (SELECT user_id FROM target_users)
RETURNING id;
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As part of designing new Admin APIs we are defining REST API guidelines for Keycloak. The aim is to eventually provide a much better and improved Admin API v2.
We will eventually break down API guidelines into distinct areas to discuss further in separate discussions. This discussion is mainly about gathering information of what problems exists with the current APIs.
Beta Was this translation helpful? Give feedback.
All reactions