Skip to content

Commit

Permalink
Merge pull request #24946 from sberyozkin/fix_kc_devservice_reload_pr…
Browse files Browse the repository at this point in the history
…oblem

Make the config available to Keycloak Dev Console after reload
  • Loading branch information
gsmet authored Apr 15, 2022
2 parents 7494b3a + d60ca02 commit 7af5d4c
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.attribute.FileTime;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand All @@ -24,6 +25,7 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -155,7 +157,14 @@ public DevServicesResultBuildItem startKeycloakContainer(
}
}
if (!restartRequired) {
return devService.toBuildItem();
DevServicesResultBuildItem result = devService.toBuildItem();
String usersString = result.getConfig().get(OIDC_USERS);
Map<String, String> users = (usersString == null || usersString.isBlank()) ? Map.of()
: Arrays.stream(usersString.split(","))
.map(s -> s.split("=")).collect(Collectors.toMap(s -> s[0], s -> s[1]));
keycloakBuildItemBuildProducer
.produce(new KeycloakDevServicesConfigBuildItem(result.getConfig(), Map.of(OIDC_USERS, users)));
return result;
}
try {
devService.close();
Expand Down Expand Up @@ -257,6 +266,8 @@ private Map<String, String> prepareConfiguration(
configProperties.put(APPLICATION_TYPE_CONFIG_KEY, oidcApplicationType);
configProperties.put(CLIENT_ID_CONFIG_KEY, oidcClientId);
configProperties.put(CLIENT_SECRET_CONFIG_KEY, oidcClientSecret);
configProperties.put(OIDC_USERS, users.entrySet().stream()
.map(e -> e.toString()).collect(Collectors.joining(",")));

keycloakBuildItemBuildProducer
.produce(new KeycloakDevServicesConfigBuildItem(configProperties, Map.of(OIDC_USERS, users)));
Expand Down

0 comments on commit 7af5d4c

Please sign in to comment.