Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateRealm doesn't work if realm name is changed #485

Open
bs-patrik opened this issue Sep 11, 2024 · 0 comments
Open

UpdateRealm doesn't work if realm name is changed #485

bs-patrik opened this issue Sep 11, 2024 · 0 comments

Comments

@bs-patrik
Copy link

bs-patrik commented Sep 11, 2024

Describe the bug
The PUT /admin/realms/{realm} endpoint in the Keycloak API has a path parameter with the realm name and the request body with the RealmRepresentation. The gocloak library use it wrongly, because in the UpdateRealm method only the RealmRepresentation passed and the realm name from there is used as the path parameter. In case that is changed the updated fails.
Based on the Keycloak API the name of the original realm should be passed as the path parameter.

To Reproduce
Call gocloak.UpdateRealm method with a changed realm name.

Expected behavior
The realm name in Keycloak is updated.

Temporary I could fix it like this:
`// UpdateRealm updates a given realm
func (g *GoCloak) UpdateRealm(ctx context.Context, token string, realm RealmRepresentation, realmToUpdate string) error {
const errMessage = "could not update realm"

resp, err := g.GetRequestWithBearerAuth(ctx, token).
	SetBody(realm).
	Put(g.getAdminRealmURL(realmToUpdate))

return checkForError(resp, err, errMessage)

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant