Browse Source
fix: improve KeycloakAdmin.get_client_id() performances (#511)
Co-authored-by: Aurélien Alet <aurelien.alet@cdbdx.biz>
pull/545/head
v3.10.1
Aurélien Alet
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
2 deletions
-
src/keycloak/keycloak_admin.py
-
src/keycloak/urls_patterns.py
|
|
@ -1580,9 +1580,13 @@ class KeycloakAdmin: |
|
|
|
:return: client_id (uuid as string) |
|
|
|
:rtype: str |
|
|
|
""" |
|
|
|
clients = self.get_clients() |
|
|
|
params_path = {"realm-name": self.connection.realm_name, "client-id": client_id} |
|
|
|
data_raw = self.connection.raw_get( |
|
|
|
urls_patterns.URL_ADMIN_CLIENTS_CLIENT_ID.format(**params_path) |
|
|
|
) |
|
|
|
data_response = raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
for client in clients: |
|
|
|
for client in data_response: |
|
|
|
if client_id == client.get("clientId"): |
|
|
|
return client["id"] |
|
|
|
|
|
|
|
|
|
@ -90,6 +90,7 @@ URL_ADMIN_GROUP_MEMBERS = "admin/realms/{realm-name}/groups/{id}/members" |
|
|
|
URL_ADMIN_CLIENT_INITIAL_ACCESS = "admin/realms/{realm-name}/clients-initial-access" |
|
|
|
URL_ADMIN_CLIENTS = "admin/realms/{realm-name}/clients" |
|
|
|
URL_ADMIN_CLIENT = URL_ADMIN_CLIENTS + "/{id}" |
|
|
|
URL_ADMIN_CLIENTS_CLIENT_ID = URL_ADMIN_CLIENTS + "?clientId={client-id}" |
|
|
|
URL_ADMIN_CLIENT_ALL_SESSIONS = URL_ADMIN_CLIENT + "/user-sessions" |
|
|
|
URL_ADMIN_CLIENT_SECRETS = URL_ADMIN_CLIENT + "/client-secret" |
|
|
|
URL_ADMIN_CLIENT_ROLES = URL_ADMIN_CLIENT + "/roles" |
|
|
|