You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
initialize-benchmark-entities.sh fail to create clients #1133
The function create_oidc_client in the script initialize-benchmark-entities.sh has a hard-coded clientId and secret name failing to create clients required for benchmarking.
@burigolucas Unfortunately, I needed to revert changes introduced in #1134. It seems there was a misunderstanding about the purpose of -c parameter for initialize-benchmark-entities.sh.
This script is creating two clients, one with service account enabled, and the second without. CLIENT_ID variable is supposed to be used only for the first one. We cannot use the same as clientId needs to be different for the second client. Feel free to open a PR where you add another parameter for the script with the input defaulting to client-0 if you need this.
Hi @mhajas, thanks for getting back to me. There are a few points that needs to be revised:
Both function create_service_enabled_client_assign_roles and create_oidc_client create clients with service account enabled. I propose we change the function create_oidc_client in order to not enable the service account.
Hard-coding a clientId breaks the script when executing it a second time since the client already exists.
I propose the following changes:
add a parameter -s for the service account name, with default value of gatling
use the parameter -c for the oidc client, with default value of client-0
Finally, we need to agree on how to handle duplicated entries. Right now, the script will exit after failed to create a client that already exists, therefore not creating the user. We could either always check if it exists before creating the entity like it is done for the realm, but this will be very slow. Another option is to only try creating the entity if the parameter is set. The a user can easily use the script several times, for example in a loop, to create multiple entities in the same realm. For the service account, I propose we check if it exists first, like it is done for the realm as I assume there is no need to create many such entities.
Both function create_service_enabled_client_assign_roles and create_oidc_client create clients with service account enabled. I propose we change the function create_oidc_client in order to not enable the service account.
I am afraid we can't do this. This can be a breaking change for some users. People can use the client-0 also for client credentials grant.
add a parameter -s for the service account name, with default value of gatling
use the parameter -c for the oidc client, with default value of client-0
I like your suggestion, however, I am again afraid this may be a breaking change for people using this script. I would prefer keeping -c as is and add one more parameter for setting name for currently hardcoded clientId.
Maybe we can go with -t as testing client id?
Finally, we need to agree on how to handle duplicated entries. Right now, the script will exit after failed to create a client that already exists, therefore not creating the user. We could either always check if it exists before creating the entity like it is done for the realm, but this will be very slow. Another option is to only try creating the entity if the parameter is set. The a user can easily use the script several times, for example in a loop, to create multiple entities in the same realm. For the service account, I propose we check if it exists first, like it is done for the realm as I assume there is no need to create many such entities.
We could add one more boolean option that enables behavior that checks whether client exists before creating it.
Another idea is to add an option to admin client cli that considers 409 response code as success for create command when specified.
Also, I am not sure I understand the slowness concerns you have. Do you use this script to create many clients? Have you considered using Keycloak dataset provider for that? It should be much faster than admin client.
Activity
Fix create_oidc_client
mhajas commentedon Apr 16, 2025
@burigolucas Unfortunately, I needed to revert changes introduced in #1134. It seems there was a misunderstanding about the purpose of
-cparameter forinitialize-benchmark-entities.sh.This script is creating two clients, one with service account enabled, and the second without.
CLIENT_IDvariable is supposed to be used only for the first one. We cannot use the same as clientId needs to be different for the second client. Feel free to open a PR where you add another parameter for the script with the input defaulting toclient-0if you need this.burigolucas commentedon Apr 17, 2025
Hi @mhajas, thanks for getting back to me. There are a few points that needs to be revised:
function create_service_enabled_client_assign_rolesandcreate_oidc_clientcreate clients with service account enabled. I propose we change the functioncreate_oidc_clientin order to not enable the service account.I propose the following changes:
Finally, we need to agree on how to handle duplicated entries. Right now, the script will exit after failed to create a client that already exists, therefore not creating the user. We could either always check if it exists before creating the entity like it is done for the realm, but this will be very slow. Another option is to only try creating the entity if the parameter is set. The a user can easily use the script several times, for example in a loop, to create multiple entities in the same realm. For the service account, I propose we check if it exists first, like it is done for the realm as I assume there is no need to create many such entities.
What do you think?
mhajas commentedon Apr 24, 2025
I am afraid we can't do this. This can be a breaking change for some users. People can use the
client-0also for client credentials grant.I like your suggestion, however, I am again afraid this may be a breaking change for people using this script. I would prefer keeping
-cas is and add one more parameter for setting name for currently hardcodedclientId.Maybe we can go with
-tas testing client id?We could add one more boolean option that enables behavior that checks whether client exists before creating it.
Another idea is to add an option to admin client cli that considers 409 response code as success for create command when specified.
Also, I am not sure I understand the slowness concerns you have. Do you use this script to create many clients? Have you considered using Keycloak dataset provider for that? It should be much faster than admin client.