diff --git a/quarkus/deployment/pom.xml b/quarkus/deployment/pom.xml index cc3e2550b3..df7e4a9041 100644 --- a/quarkus/deployment/pom.xml +++ b/quarkus/deployment/pom.xml @@ -62,6 +62,10 @@ io.quarkus quarkus-jdbc-mssql-deployment + + io.quarkus + quarkus-jdbc-oracle-deployment + io.quarkus quarkus-bootstrap-core diff --git a/quarkus/runtime/pom.xml b/quarkus/runtime/pom.xml index 19999a2d65..dc8135dd20 100644 --- a/quarkus/runtime/pom.xml +++ b/quarkus/runtime/pom.xml @@ -63,6 +63,10 @@ io.quarkus quarkus-jdbc-mssql + + io.quarkus + quarkus-jdbc-oracle + io.quarkus quarkus-core diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/EnvConfigSource.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KcEnvConfigSource.java similarity index 62% rename from quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/EnvConfigSource.java rename to quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KcEnvConfigSource.java index 0536fdce93..a97aec066c 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/EnvConfigSource.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KcEnvConfigSource.java @@ -17,46 +17,34 @@ 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 java.util.HashMap; 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 properties = new TreeMap<>(); +public class KcEnvConfigSource extends EnvConfigSource { + + private static Map buildProperties() { + Map properties = new HashMap<>(); - public EnvConfigSource() { for (Map.Entry entry : System.getenv().entrySet()) { 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()); } } - } - @Override - public Map getProperties() { return properties; } - @Override - public Set getPropertyNames() { - return properties.keySet(); - } - - public String getValue(final String propertyName) { - return System.getProperty(propertyName); + public KcEnvConfigSource() { + super(buildProperties(), 350); } public String getName() { return "KcEnvVarConfigSource"; } - - @Override - public int getOrdinal() { - return 350; - } } diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KeycloakConfigSourceProvider.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KeycloakConfigSourceProvider.java index 25b3cea01c..2c509d110c 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KeycloakConfigSourceProvider.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/KeycloakConfigSourceProvider.java @@ -53,7 +53,7 @@ public class KeycloakConfigSourceProvider implements ConfigSourceProvider { CONFIG_SOURCES.add(new ConfigArgsConfigSource()); CONFIG_SOURCES.add(new SysPropConfigSource()); - CONFIG_SOURCES.add(new EnvConfigSource()); + CONFIG_SOURCES.add(new KcEnvConfigSource()); PERSISTED_CONFIG_SOURCE = new PersistedConfigSource(getPersistedConfigFile()); CONFIG_SOURCES.add(PERSISTED_CONFIG_SOURCE); diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/Database.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/Database.java index 79e05ca118..6a32dceede 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/Database.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/storage/database/Database.java @@ -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:}", asList("org.keycloak.quarkus.runtime.storage.database.liquibase.database.CustomMSSQLDatabase"), "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; diff --git a/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java b/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java index 1375c30c11..dd285bf8e6 100644 --- a/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java +++ b/quarkus/runtime/src/test/java/org/keycloak/provider/quarkus/ConfigurationTest.java @@ -18,6 +18,7 @@ package org.keycloak.provider.quarkus; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.keycloak.quarkus.runtime.Environment.CLI_ARGS; import java.io.File; @@ -117,6 +118,15 @@ public class ConfigurationTest { 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 public void testSysPropPriorityOverEnvVar() { putEnvVar("KC_SPI_HOSTNAME_DEFAULT_FRONTEND_URL", "http://envvar.unittest");