[KEYCLOAK-19310] - Oracle Support
This commit is contained in:
parent
951a232b24
commit
6071e2d518
6 changed files with 35 additions and 23 deletions
|
@ -62,6 +62,10 @@
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-jdbc-mssql-deployment</artifactId>
|
<artifactId>quarkus-jdbc-mssql-deployment</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-jdbc-oracle-deployment</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-bootstrap-core</artifactId>
|
<artifactId>quarkus-bootstrap-core</artifactId>
|
||||||
|
|
|
@ -63,6 +63,10 @@
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-jdbc-mssql</artifactId>
|
<artifactId>quarkus-jdbc-mssql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-jdbc-oracle</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-core</artifactId>
|
<artifactId>quarkus-core</artifactId>
|
||||||
|
|
|
@ -17,46 +17,34 @@
|
||||||
|
|
||||||
package org.keycloak.quarkus.runtime.configuration;
|
package org.keycloak.quarkus.runtime.configuration;
|
||||||
|
|
||||||
|
import static io.smallrye.config.common.utils.StringUtil.replaceNonAlphanumericByUnderscores;
|
||||||
import static org.keycloak.quarkus.runtime.configuration.Configuration.getMappedPropertyName;
|
import static org.keycloak.quarkus.runtime.configuration.Configuration.getMappedPropertyName;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import org.eclipse.microprofile.config.spi.ConfigSource;
|
|
||||||
|
|
||||||
public class EnvConfigSource implements ConfigSource {
|
import io.smallrye.config.EnvConfigSource;
|
||||||
|
|
||||||
private final Map<String, String> properties = new TreeMap<>();
|
public class KcEnvConfigSource extends EnvConfigSource {
|
||||||
|
|
||||||
|
private static Map<String, String> buildProperties() {
|
||||||
|
Map<String, String> properties = new HashMap<>();
|
||||||
|
|
||||||
public EnvConfigSource() {
|
|
||||||
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
|
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
if (key.startsWith(MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX.toUpperCase().replace('.', '_'))) {
|
if (key.startsWith(replaceNonAlphanumericByUnderscores(MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX.toUpperCase()))) {
|
||||||
properties.put(getMappedPropertyName(key), entry.getValue());
|
properties.put(getMappedPropertyName(key), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> getProperties() {
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public KcEnvConfigSource() {
|
||||||
public Set<String> getPropertyNames() {
|
super(buildProperties(), 350);
|
||||||
return properties.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue(final String propertyName) {
|
|
||||||
return System.getProperty(propertyName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "KcEnvVarConfigSource";
|
return "KcEnvVarConfigSource";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrdinal() {
|
|
||||||
return 350;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -53,7 +53,7 @@ public class KeycloakConfigSourceProvider implements ConfigSourceProvider {
|
||||||
|
|
||||||
CONFIG_SOURCES.add(new ConfigArgsConfigSource());
|
CONFIG_SOURCES.add(new ConfigArgsConfigSource());
|
||||||
CONFIG_SOURCES.add(new SysPropConfigSource());
|
CONFIG_SOURCES.add(new SysPropConfigSource());
|
||||||
CONFIG_SOURCES.add(new EnvConfigSource());
|
CONFIG_SOURCES.add(new KcEnvConfigSource());
|
||||||
PERSISTED_CONFIG_SOURCE = new PersistedConfigSource(getPersistedConfigFile());
|
PERSISTED_CONFIG_SOURCE = new PersistedConfigSource(getPersistedConfigFile());
|
||||||
CONFIG_SOURCES.add(PERSISTED_CONFIG_SOURCE);
|
CONFIG_SOURCES.add(PERSISTED_CONFIG_SOURCE);
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,12 @@ public final class Database {
|
||||||
"jdbc:sqlserver://${kc.db.url.host:localhost}:1433;databaseName=${kc.db.url.database:keycloak}${kc.db.url.properties:}",
|
"jdbc:sqlserver://${kc.db.url.host:localhost}:1433;databaseName=${kc.db.url.database:keycloak}${kc.db.url.properties:}",
|
||||||
asList("org.keycloak.quarkus.runtime.storage.database.liquibase.database.CustomMSSQLDatabase"),
|
asList("org.keycloak.quarkus.runtime.storage.database.liquibase.database.CustomMSSQLDatabase"),
|
||||||
"mssql", "mssql-2012"
|
"mssql", "mssql-2012"
|
||||||
|
),
|
||||||
|
ORACLE("oracle",
|
||||||
|
"oracle.jdbc.xa.client.OracleXADataSource",
|
||||||
|
"org.hibernate.dialect.Oracle12cDialect",
|
||||||
|
"jdbc:oracle:thin:@//${kc.db.url.host:localhost}:1521/${kc.db.url.database:keycloak}",
|
||||||
|
asList("liquibase.database.core.OracleDatabase")
|
||||||
);
|
);
|
||||||
|
|
||||||
final String databaseKind;
|
final String databaseKind;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.keycloak.provider.quarkus;
|
package org.keycloak.provider.quarkus;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.keycloak.quarkus.runtime.Environment.CLI_ARGS;
|
import static org.keycloak.quarkus.runtime.Environment.CLI_ARGS;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -117,6 +118,15 @@ public class ConfigurationTest {
|
||||||
assertEquals("http://envvar.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
assertEquals("http://envvar.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnvVarAvailableFromPropertyNames() {
|
||||||
|
putEnvVar("KC_VAULT_FILE_PATH", "/foo/bar");
|
||||||
|
Config.Scope config = initConfig("vault", FilesPlainTextVaultProviderFactory.PROVIDER_ID);
|
||||||
|
assertEquals("/foo/bar", config.get("dir"));
|
||||||
|
assertTrue(config.getPropertyNames()
|
||||||
|
.contains("kc.spi.vault.".concat(FilesPlainTextVaultProviderFactory.PROVIDER_ID).concat(".dir")));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSysPropPriorityOverEnvVar() {
|
public void testSysPropPriorityOverEnvVar() {
|
||||||
putEnvVar("KC_SPI_HOSTNAME_DEFAULT_FRONTEND_URL", "http://envvar.unittest");
|
putEnvVar("KC_SPI_HOSTNAME_DEFAULT_FRONTEND_URL", "http://envvar.unittest");
|
||||||
|
|
Loading…
Reference in a new issue