mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-30 11:29:57 -06:00
Removing unnecessary configuration from auth servers
Closes #35604 Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
committed by
Alexander Schwartz
parent
0836db33f0
commit
5c901016e7
@@ -17,8 +17,6 @@
|
||||
|
||||
package org.keycloak.common.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -26,21 +24,9 @@ import java.util.Properties;
|
||||
*/
|
||||
public class SystemEnvProperties extends Properties {
|
||||
|
||||
private final Map<String, String> overrides;
|
||||
|
||||
public SystemEnvProperties(Map<String, String> overrides) {
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
||||
public SystemEnvProperties() {
|
||||
this.overrides = Collections.EMPTY_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
if (overrides.containsKey(key)) {
|
||||
return overrides.get(key);
|
||||
} else if (key.startsWith("env.")) {
|
||||
if (key.startsWith("env.")) {
|
||||
return System.getenv().get(key.substring(4));
|
||||
} else {
|
||||
return System.getProperty(key);
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.keycloak.services.DefaultKeycloakSessionFactory;
|
||||
import org.keycloak.services.managers.ApplianceBootstrap;
|
||||
import org.keycloak.services.resources.KeycloakApplication;
|
||||
import org.keycloak.services.resteasy.ResteasyKeycloakApplication;
|
||||
import org.keycloak.testsuite.JsonConfigProviderFactory;
|
||||
import org.keycloak.testsuite.KeycloakServer;
|
||||
import org.keycloak.testsuite.UndertowRequestFilter;
|
||||
import org.keycloak.testsuite.utils.tls.TLSUtils;
|
||||
@@ -94,15 +93,6 @@ public class KeycloakOnUndertow implements DeployableContainer<KeycloakOnUnderto
|
||||
di.setContextPath("/auth");
|
||||
di.setDeploymentName("Keycloak");
|
||||
di.setDefaultEncoding("UTF-8");
|
||||
if (configuration.getKeycloakConfigPropertyOverridesMap() != null) {
|
||||
try {
|
||||
di.addInitParameter(JsonConfigProviderFactory.SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES,
|
||||
JsonSerialization.writeValueAsString(configuration.getKeycloakConfigPropertyOverridesMap()));
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
di.setDefaultServletConfig(new DefaultServletConfig(true));
|
||||
di.addWelcomePage("theme/keycloak/welcome/resources/index.html");
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ public class KeycloakOnUndertowConfiguration extends UndertowContainerConfigurat
|
||||
private boolean remoteMode;
|
||||
private String route;
|
||||
private String keycloakConfigPropertyOverrides;
|
||||
private HashMap<String, Object> keycloakConfigPropertyOverridesMap;
|
||||
|
||||
private int bindHttpPortOffset = 0;
|
||||
private int bindHttpsPortOffset = 0;
|
||||
@@ -99,18 +98,6 @@ public class KeycloakOnUndertowConfiguration extends UndertowContainerConfigurat
|
||||
this.remoteMode = remoteMode;
|
||||
}
|
||||
|
||||
public String getKeycloakConfigPropertyOverrides() {
|
||||
return keycloakConfigPropertyOverrides;
|
||||
}
|
||||
|
||||
public void setKeycloakConfigPropertyOverrides(String keycloakConfigPropertyOverrides) {
|
||||
this.keycloakConfigPropertyOverrides = keycloakConfigPropertyOverrides;
|
||||
}
|
||||
|
||||
public Map<String, Object> getKeycloakConfigPropertyOverridesMap() {
|
||||
return keycloakConfigPropertyOverridesMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws ConfigurationException {
|
||||
super.validate();
|
||||
@@ -125,15 +112,6 @@ public class KeycloakOnUndertowConfiguration extends UndertowContainerConfigurat
|
||||
|
||||
log.info("KeycloakOnUndertow will listen for http on port: " + newPort + " and for https on port: " + newHttpsPort);
|
||||
|
||||
if (this.keycloakConfigPropertyOverrides != null) {
|
||||
try {
|
||||
TypeReference<HashMap<String,Object>> typeRef = new TypeReference<HashMap<String,Object>>() {};
|
||||
this.keycloakConfigPropertyOverridesMap = JsonSerialization.sysPropertiesAwareMapper.readValue(this.keycloakConfigPropertyOverrides, typeRef);
|
||||
} catch (IOException ex) {
|
||||
throw new ConfigurationException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO validate workerThreads
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public class KeycloakQuarkusConfiguration implements ContainerConfiguration {
|
||||
private int startupTimeoutInSeconds = 300;
|
||||
private String route;
|
||||
private String keycloakConfigPropertyOverrides;
|
||||
private HashMap<String, Object> keycloakConfigPropertyOverridesMap;
|
||||
private String profile;
|
||||
private String javaOpts;
|
||||
private boolean reaugmentBeforeStart;
|
||||
@@ -62,15 +61,6 @@ public class KeycloakQuarkusConfiguration implements ContainerConfiguration {
|
||||
setBindHttpsPort(newHttpsPort);
|
||||
|
||||
log.infof("Keycloak will listen for http on port: %d, for https on port: %d, and for management on port: %d\n", newPort, newHttpsPort, managementPort);
|
||||
|
||||
if (this.keycloakConfigPropertyOverrides != null) {
|
||||
try {
|
||||
TypeReference<HashMap<String,Object>> typeRef = new TypeReference<HashMap<String,Object>>() {};
|
||||
this.keycloakConfigPropertyOverridesMap = JsonSerialization.sysPropertiesAwareMapper.readValue(this.keycloakConfigPropertyOverrides, typeRef);
|
||||
} catch (IOException ex) {
|
||||
throw new ConfigurationException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getBindHttpPortOffset() {
|
||||
@@ -182,18 +172,6 @@ public class KeycloakQuarkusConfiguration implements ContainerConfiguration {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getKeycloakConfigPropertyOverrides() {
|
||||
return keycloakConfigPropertyOverrides;
|
||||
}
|
||||
|
||||
public void setKeycloakConfigPropertyOverrides(String keycloakConfigPropertyOverrides) {
|
||||
this.keycloakConfigPropertyOverrides = keycloakConfigPropertyOverrides;
|
||||
}
|
||||
|
||||
public Map<String, Object> getKeycloakConfigPropertyOverridesMap() {
|
||||
return keycloakConfigPropertyOverridesMap;
|
||||
}
|
||||
|
||||
public void setJavaOpts(String javaOpts) {
|
||||
this.javaOpts = javaOpts;
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.keycloak.testsuite;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.jboss.resteasy.core.ResteasyContext;
|
||||
import org.keycloak.common.util.SystemEnvProperties;
|
||||
import org.keycloak.util.JsonSerialization;
|
||||
|
||||
public class JsonConfigProviderFactory extends org.keycloak.services.util.JsonConfigProviderFactory {
|
||||
|
||||
public static final String SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES = "keycloak.server.context.config.property-overrides";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
return new SystemEnvProperties(getPropertyOverrides());
|
||||
}
|
||||
|
||||
private Map<String, String> getPropertyOverrides() {
|
||||
|
||||
ServletContext context = ResteasyContext.getContextData(ServletContext.class);
|
||||
Map<String, String> propertyOverridesMap = new HashMap<>();
|
||||
String propertyOverrides = context.getInitParameter(SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES);
|
||||
|
||||
try {
|
||||
if (context.getInitParameter(SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES) != null) {
|
||||
JsonNode jsonObj = JsonSerialization.mapper.readTree(propertyOverrides);
|
||||
jsonObj.fields().forEachRemaining(e -> propertyOverridesMap.put(e.getKey(), e.getValue().asText()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
return propertyOverridesMap;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user