Nerzal / gocloak

golang keycloak client
Apache License 2.0
1.01k stars 275 forks source link

UpdateClient does not update defaultClientScopes #476

Closed Mikakakaka closed 3 months ago

Mikakakaka commented 3 months ago

Keycloak seems to have issues updating client scopes and i have this problem using Gocloak.

I can create a client with the scopes list but when i update an existing client, everything is taken into account exept the defaultClientScopes.

Is it a bug, am I missing something, or is the bug related to Keycloak?

Context

Thanks in advance

osamaadam commented 3 months ago

I ran into a similar situation. This is a Keycloak thing. Make sure the client scope you're trying to make default doesn't already exist in the list of optional client scopes. Unfortunately Keycloak doesn't handle this gracefully and the same client scope could exist in both optionalClientScopes and defaultClientScopes and in this case the optionalClientScopes list takes precedence.

See RemoveOptionalScopeFromClient and AddDefaultScopeToClient.

Mikakakaka commented 3 months ago

Thanks a lot. My clients had no optional client scopes but removing every single scope manualy and adding them one by one worked for me. As you suggested in the last part of your message, i used RemoveDefaultScopeFromClient and then AddDefaultScopeToClient using the updated list.