Skip to content

Commit

Permalink
Do not enforce access when updating unmanaged attributes setting when…
Browse files Browse the repository at this point in the history
… updating a realm

Closes keycloak#34540

Signed-off-by: Pedro Igor <[email protected]>
  • Loading branch information
pedroigor committed Nov 1, 2024
1 parent a7af380 commit 3e88568
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.keycloak.admin.ui.rest.model.UIRealmRepresentation;
import org.keycloak.admin.ui.rest.model.UIRealmInfo;
import org.keycloak.component.ComponentValidationException;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.StorageProviderRealmModel;
import org.keycloak.representations.userprofile.config.UPConfig;
Expand All @@ -43,6 +44,7 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status.Family;
import org.keycloak.userprofile.UserProfileProvider;

/**
* This JAX-RS resource is decorating the Admin Realm API in order to support specific behaviors from the
Expand Down Expand Up @@ -102,15 +104,17 @@ private void updateUserProfileConfiguration(UIRealmRepresentation rep) {
return;
}

UserProfileResource userProfileResource = new UserProfileResource(session, auth, adminEvent);
if (!upConfig.equals(userProfileResource.getConfiguration())) {
Response response = userProfileResource.update(upConfig);
UserProfileProvider provider = session.getProvider(UserProfileProvider.class);
UPConfig current = provider.getConfiguration();

if (isSuccessful(response)) {
return;
if (!upConfig.equals(current)) {
try {
provider.setConfiguration(upConfig);
} catch (ComponentValidationException cve) {
throw new InternalServerErrorException("Failed to update user profile configuration", cve);
}

throw new InternalServerErrorException("Failed to update user profile configuration");
provider.setConfiguration(upConfig);
}
}

Expand Down

0 comments on commit 3e88568

Please sign in to comment.