-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
admin/ui
Describe the bug
I am experiencing an issue with my implementation of the ThemeUiTab class. The implementation works correctly when updating the realm attribute using the administrative interface. However, when I use the REST API to update the realm attribute, the new attribute is saved (as confirmed by checking Keycloak's database), but the input field in the administrative interface still displays the old value, saved using the administrative interface.
I have tried reloading Keycloak, but the interface does not load the new value from the database.
For reference, I implemented the example from the following repository:
https://github.com/keycloak/keycloak-quickstarts/blob/latest/extension/extend-admin-console-spi/src/main/java/org/keycloak/admin/ui/ThemeUiTab.java
Version
26.0.7
Regression
- The issue is a regression
Expected behavior
The input created added to the realm attributes shoud load the data store on the database, regardless of how it was saved (by using the interface or by using the rest api)
Actual behavior
The input keeps the last value stored using the adminstrative interface
How to Reproduce?
- Implement a custom SPI to add the realm attribute to the interface, as this example:
package org.keycloak.admin.ui;
import org.keycloak.Config;
import org.keycloak.component.ComponentModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderConfigurationBuilder;
import org.keycloak.services.ui.extend.UiTabProvider;
import org.keycloak.services.ui.extend.UiTabProviderFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ThemeUiTab implements UiTabProvider, UiTabProviderFactory<ComponentModel> {
@Override
public String getId() {
return "Attributes";
}
@Override
public String getHelpText() {
return null;
}
@Override
public void init(Config.Scope config) {
}
@Override
public void postInit(KeycloakSessionFactory factory) {
}
@Override
public void close() {
}
@Override
public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
realm.setAttribute("userauthurl", model.get("userauthurl"));
}
@Override
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
realm.setAttribute("userauthurl", newModel.get("userauthurl"));
}
@Override
public List<ProviderConfigProperty> getConfigProperties() {
final ProviderConfigurationBuilder builder = ProviderConfigurationBuilder.create();
builder.property()
.name("userauthurl")
.label("User Authorization Data Host")
.helpText("The host used by Keycloak to fetch user authorization data (perfis do VirtualIF) and add them to the token.")
.type(ProviderConfigProperty.STRING_TYPE)
.add();
return builder.build();
}
@Override
public String getPath() {
return "/:realm/realm-settings/:tab?";
}
@Override
public Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tab", "attributes");
return params;
}
}- Enable
DECLARATIVE_UIon Keycloak server and restart. - Save a value to the realm attribute using the administrative interface.
- Check the saved value on the interface and on Keycloak's database
- Use the REST API to change this value (PUT request to
admin/realms/{realm-id}passing in the body:
{
"attributes": {
"userauthurl": "http://api.homologacao6virtualif.iftm.edu.br"
}
}- Check the value on the database and Keycloak administrative UI
Anything else?
Thanks in advance for the greate work!