From 1a641617bd31ce0f3e0cc53faa1a1846280cb52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Mon, 10 Jul 2023 15:57:03 +0200 Subject: [PATCH] Fix OIDC DEV UI hot reload --- .../devservices/AbstractDevConsoleProcessor.java | 3 ++- .../devservices/keycloak/KeycloakDevConsoleProcessor.java | 6 +++++- .../quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java | 3 ++- .../io/quarkus/oidc/runtime/devui/OidcDevUiRecorder.java | 3 ++- .../oidc/runtime/devui/OidcDevUiRpcSvcPropertiesBean.java | 7 ++++--- .../oidc/runtime/devui/OidcDevUiRuntimePropertiesDTO.java | 8 +++++--- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevConsoleProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevConsoleProcessor.java index 3ecb6ede54846..ddfe711e52275 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevConsoleProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/AbstractDevConsoleProcessor.java @@ -1,6 +1,7 @@ package io.quarkus.oidc.deployment.devservices; import java.time.Duration; +import java.util.List; import java.util.Map; import jakarta.inject.Singleton; @@ -109,7 +110,7 @@ protected static CardPageBuildItem createProviderWebComponent(OidcDevUiRecorder ConfigurationBuildItem configurationBuildItem, String keycloakAdminUrl, Map keycloakUsers, - Object keycloakRealms, + List keycloakRealms, boolean alwaysLogoutUserInDevUiOnReload) { final CardPageBuildItem cardPage = new CardPageBuildItem(); diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java index 3aa2515cb9a4f..0f32d572e9861 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java @@ -1,5 +1,6 @@ package io.quarkus.oidc.deployment.devservices.keycloak; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -84,6 +85,9 @@ void produceProviderComponent(Optional confi String keycloakAdminUrl = configProps.get().getConfig().get("keycloak.url"); + @SuppressWarnings("unchecked") + final List keycloakRealms = (List) configProps.get().getProperties().get("keycloak.realms"); + CardPageBuildItem cardPageBuildItem = createProviderWebComponent( recorder, capabilities, @@ -102,7 +106,7 @@ void produceProviderComponent(Optional confi configurationBuildItem, keycloakAdminUrl, users, - configProps.get().getProperties().get("keycloak.realms"), + keycloakRealms, configProps.get().isContainerRestarted()); // Also add Admin page diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java index d2f023af83f6d..e54c728dbe077 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevJsonRpcService.java @@ -3,6 +3,7 @@ import static io.quarkus.oidc.runtime.devui.OidcDevServicesUtils.getTokens; import java.time.Duration; +import java.util.List; import java.util.Map; import io.quarkus.arc.Arc; @@ -30,7 +31,7 @@ public class OidcDevJsonRpcService { private final String oidcGrantType; private final boolean introspectionIsAvailable; private final String keycloakAdminUrl; - private final Object keycloakRealms; + private final List keycloakRealms; private final boolean swaggerIsAvailable; private final boolean graphqlIsAvailable; private final String swaggerUiPath; diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRecorder.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRecorder.java index 9843429da4030..a30dda814db89 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRecorder.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRecorder.java @@ -1,6 +1,7 @@ package io.quarkus.oidc.runtime.devui; import java.time.Duration; +import java.util.List; import java.util.Map; import java.util.function.Supplier; @@ -11,7 +12,7 @@ public class OidcDevUiRecorder { public Supplier prepareRpcServiceProperties(String authorizationUrl, String tokenUrl, String logoutUrl, Duration webClientTimeout, Map> grantOptions, Map oidcUsers, String oidcProviderName, String oidcApplicationType, String oidcGrantType, - boolean introspectionIsAvailable, String keycloakAdminUrl, Object keycloakRealms, boolean swaggerIsAvailable, + boolean introspectionIsAvailable, String keycloakAdminUrl, List keycloakRealms, boolean swaggerIsAvailable, boolean graphqlIsAvailable, String swaggerUiPath, String graphqlUiPath, boolean alwaysLogoutUserInDevUiOnReload) { return new Supplier() { @Override diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRpcSvcPropertiesBean.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRpcSvcPropertiesBean.java index d31482bd48802..4349166bd9e43 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRpcSvcPropertiesBean.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRpcSvcPropertiesBean.java @@ -1,6 +1,7 @@ package io.quarkus.oidc.runtime.devui; import java.time.Duration; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -17,7 +18,7 @@ public class OidcDevUiRpcSvcPropertiesBean { private final String oidcGrantType; private final boolean introspectionIsAvailable; private final String keycloakAdminUrl; - private final Object keycloakRealms; + private final List keycloakRealms; private final boolean swaggerIsAvailable; private final boolean graphqlIsAvailable; private final String swaggerUiPath; @@ -33,7 +34,7 @@ public class OidcDevUiRpcSvcPropertiesBean { Duration webClientTimeout, Map> grantOptions, Map oidcUsers, String oidcProviderName, String oidcApplicationType, String oidcGrantType, boolean introspectionIsAvailable, String keycloakAdminUrl, - Object keycloakRealms, boolean swaggerIsAvailable, boolean graphqlIsAvailable, + List keycloakRealms, boolean swaggerIsAvailable, boolean graphqlIsAvailable, String swaggerUiPath, String graphqlUiPath, boolean alwaysLogoutUserInDevUiOnReload) { this.authorizationUrl = authorizationUrl; this.tokenUrl = tokenUrl; @@ -95,7 +96,7 @@ String getKeycloakAdminUrl() { return keycloakAdminUrl; } - Object getKeycloakRealms() { + List getKeycloakRealms() { return keycloakRealms; } diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRuntimePropertiesDTO.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRuntimePropertiesDTO.java index cd0d9c723a5eb..743e0b86426b6 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRuntimePropertiesDTO.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/devui/OidcDevUiRuntimePropertiesDTO.java @@ -1,5 +1,7 @@ package io.quarkus.oidc.runtime.devui; +import java.util.List; + import org.eclipse.microprofile.config.Config; import io.quarkus.oidc.runtime.OidcConfigPropertySupplier; @@ -26,7 +28,7 @@ public class OidcDevUiRuntimePropertiesDTO { private final String oidcGrantType; private final boolean introspectionIsAvailable; private final String keycloakAdminUrl; - private final Object keycloakRealms; + private final List keycloakRealms; private final boolean swaggerIsAvailable; private final boolean graphqlIsAvailable; private final String swaggerUiPath; @@ -36,7 +38,7 @@ public class OidcDevUiRuntimePropertiesDTO { OidcDevUiRuntimePropertiesDTO(String authorizationUrl, String tokenUrl, String logoutUrl, Config config, int httpPort, String oidcProviderName, String oidcApplicationType, String oidcGrantType, - boolean introspectionIsAvailable, String keycloakAdminUrl, Object keycloakRealms, + boolean introspectionIsAvailable, String keycloakAdminUrl, List keycloakRealms, boolean swaggerIsAvailable, boolean graphqlIsAvailable, String swaggerUiPath, String graphqlUiPath, boolean alwaysLogoutUserInDevUiOnReload, String propertiesStateId) { this.clientId = new OidcConfigPropertySupplier(CLIENT_ID_CONFIG_KEY).get(config); @@ -114,7 +116,7 @@ public String getKeycloakAdminUrl() { return keycloakAdminUrl; } - public Object getKeycloakRealms() { + public List getKeycloakRealms() { return keycloakRealms; }