Skip to content

Commit

Permalink
Upgrade to Quarkus 3.13.1
Browse files Browse the repository at this point in the history
Closes keycloak#31676

Signed-off-by: Václav Muzikář <[email protected]>
Co-authored-by: Peter Zaoral <[email protected]>
  • Loading branch information
vmuzikar and Pepo48 committed Aug 9, 2024
1 parent 347f595 commit a88f0a5
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@ when exporting a realm.

To obtain the query the identity providers in a realm, prefer using the `/realms/{realm}/identity-provider/instances` endpoint.
This endpoint supports filters and pagination.

= Keystore and trust store default format change

{project_name} now determines the format of the keystore and trust store based on the file extension. If the file extension is `.p12`, `.pkcs12` or `.pfx`, the format is PKCS12. If the file extension is `.jks`, `.keystore` or `.truststore`, the format is JKS. If the file extension is `.pem`, `.crt` or `.key`, the format is PEM.

You can still override automatic detection by specifying the `https-key-store-type` and `https-trust-store-type` explicitly. Restrictions for the FIPS strict mode stays unchanged.

NOTE: The `+spi-truststore-file-*+` options and the truststore related options `+https-trust-store-*+` are deprecated, we strongly recommend to use System Truststore. For more details refer to the relevant https://www.keycloak.org/server/keycloak-truststore[guide].
2 changes: 1 addition & 1 deletion operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
</goals>
<configuration>
<properties>
<quarkus.package.filter-optional-dependencies>true</quarkus.package.filter-optional-dependencies>
<quarkus.package.jar.filter-optional-dependencies>true</quarkus.package.jar.filter-optional-dependencies>
</properties>
</configuration>
</execution>
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<jboss.snapshots.repo.id>jboss-snapshots-repository</jboss.snapshots.repo.id>
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>

<quarkus.version>3.8.5</quarkus.version>
<quarkus.build.version>3.8.5</quarkus.build.version>
<quarkus.version>3.13.1</quarkus.version>
<quarkus.build.version>3.13.1</quarkus.build.version>

<project.build-time>${timestamp}</project.build-time>

Expand Down Expand Up @@ -115,7 +115,7 @@
<jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>2.0.0.Final</jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>
<log4j.version>1.2.17</log4j.version>
<resteasy-legacy.version>4.7.7.Final</resteasy-legacy.version>
<resteasy.version>6.2.7.Final</resteasy.version>
<resteasy.version>6.2.9.Final</resteasy.version>
<resteasy.undertow.version>${resteasy.version}</resteasy.undertow.version>
<owasp.html.sanitizer.version>20240325.1</owasp.html.sanitizer.version>
<slf4j.version>2.0.6</slf4j.version>
Expand All @@ -128,7 +128,7 @@
<undertow.version>${undertow-legacy.version}</undertow.version>
<undertow-legacy.version>2.2.24.Final</undertow-legacy.version>
<undertow-jakarta.version>2.3.2.Final</undertow-jakarta.version>
<wildfly-elytron.version>2.2.3.Final</wildfly-elytron.version>
<wildfly-elytron.version>2.5.0.Final</wildfly-elytron.version>
<elytron.undertow-server.version>1.9.0.Final</elytron.undertow-server.version>
<woodstox.version>6.0.3</woodstox.version>
<wildfly.common.quarkus.aligned.version>1.5.4.Final-format-001</wildfly.common.quarkus.aligned.version>
Expand All @@ -152,7 +152,7 @@
<com.apicatalog.titanium-json-ld.version>1.3.3</com.apicatalog.titanium-json-ld.version>
<io.setl.rdf-urdna.version>1.1</io.setl.rdf-urdna.version>

<liquibase.version>4.25.1</liquibase.version>
<liquibase.version>4.27.0</liquibase.version>
<servlet.api.30.version>1.0.2.Final</servlet.api.30.version>
<servlet.api.40.version>2.0.0.Final</servlet.api.40.version>
<twitter4j.version>4.1.2</twitter4j.version>
Expand All @@ -163,12 +163,12 @@
<postgresql.version>16</postgresql.version>
<aurora-postgresql.version>16.1</aurora-postgresql.version>
<aws-jdbc-wrapper.version>2.3.1</aws-jdbc-wrapper.version>
<postgresql-jdbc.version>42.7.2</postgresql-jdbc.version>
<postgresql-jdbc.version>42.7.3</postgresql-jdbc.version>
<mariadb.version>10.11</mariadb.version>
<mariadb-jdbc.version>3.3.3</mariadb-jdbc.version>
<mariadb-jdbc.version>3.4.0</mariadb-jdbc.version>
<mssql.version>2022-latest</mssql.version>
<!-- this is the mssql driver version also used in the Quarkus BOM -->
<mssql-jdbc.version>12.4.2.jre11</mssql-jdbc.version>
<mssql-jdbc.version>12.6.3.jre11</mssql-jdbc.version>
<oracledb.version>19.3</oracledb.version>
<!-- this is the oracle driver version also used in the Quarkus BOM -->
<oracle-jdbc.version>23.3.0.23.09</oracle-jdbc.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public enum ClientAuth {
public static final Option<String> HTTPS_KEY_STORE_TYPE = new OptionBuilder<>("https-key-store-type", String.class)
.category(OptionCategory.HTTP)
.description("The type of the key store file. " +
"If not given, the type is automatically detected based on the file name. " +
"If not given, the type is automatically detected based on the file extension. " +
"If '" + SecurityOptions.FIPS_MODE.getKey() + "' is set to '" + FipsMode.STRICT + "' and no value is set, it defaults to 'BCFKS'.")
.build();

Expand All @@ -106,7 +106,7 @@ public enum ClientAuth {
public static final Option<String> HTTPS_TRUST_STORE_TYPE = new OptionBuilder<>("https-trust-store-type", String.class)
.category(OptionCategory.HTTP)
.description("The type of the trust store file. " +
"If not given, the type is automatically detected based on the file name. " +
"If not given, the type is automatically detected based on the file extension. " +
"If '" + SecurityOptions.FIPS_MODE.getKey() + "' is set to '" + FipsMode.STRICT + "' and no value is set, it defaults to 'BCFKS'.")
.deprecated("Use the System Truststore instead, see the docs for details.")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.quarkus.agroal.spi.JdbcDriverBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
import io.quarkus.arc.deployment.BuildTimeConditionBuildItem;
import io.quarkus.arc.processor.AnnotationsTransformer;
import io.quarkus.bootstrap.logging.InitialConfigurator;
import io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem;
import io.quarkus.deployment.IsDevelopment;
Expand Down Expand Up @@ -50,10 +49,12 @@
import io.smallrye.config.ConfigValue;
import org.eclipse.microprofile.health.Readiness;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationTransformation;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
Expand Down Expand Up @@ -318,7 +319,7 @@ void configurePersistenceUnits(HibernateOrmConfig config,
List<String> userManagedEntities = new ArrayList<>();

for (PersistenceXmlDescriptorBuildItem item : descriptors) {
ParsedPersistenceXmlDescriptor descriptor = item.getDescriptor();
ParsedPersistenceXmlDescriptor descriptor = (ParsedPersistenceXmlDescriptor) item.getDescriptor();

if ("keycloak-default".equals(descriptor.getName())) {
defaultUnitDescriptor = descriptor;
Expand Down Expand Up @@ -469,7 +470,7 @@ private void configureUserDefinedPersistenceUnits(List<PersistenceXmlDescriptorB
Map<String, ProviderFactory> preConfiguredProviders, Spi spi) {
descriptors.stream()
.map(PersistenceXmlDescriptorBuildItem::getDescriptor)
.map(ParsedPersistenceXmlDescriptor::getName)
.map(PersistenceUnitDescriptor::getName)
.filter(Predicate.not("keycloak-default"::equals)).forEach((String unitName) -> {
NamedJpaConnectionProviderFactory factory = new NamedJpaConnectionProviderFactory();

Expand Down Expand Up @@ -625,9 +626,9 @@ void disableHealthCheckBean(BuildProducer<BuildTimeConditionBuildItem> removeBea
// bean without the @Readiness annotation so it won't be used as a health check on it's own.
@BuildStep
AnnotationsTransformerBuildItem disableDefaultDataSourceHealthCheck() {
return new AnnotationsTransformerBuildItem(AnnotationsTransformer.appliedToClass()
return new AnnotationsTransformerBuildItem(AnnotationTransformation.forClasses()
.whenClass(c -> c.name().equals(DotName.createSimple(DataSourceHealthCheck.class)))
.thenTransform(t -> t.remove(
.transform(t -> t.remove(
a -> a.name().equals(DotName.createSimple(Readiness.class)))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.keycloak.quarkus.runtime.cli.Picocli.println;
import static org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource.getAllCliArgs;

import io.quarkus.runtime.LaunchMode;
import org.keycloak.config.OptionCategory;
import org.keycloak.quarkus.runtime.Environment;
import org.keycloak.quarkus.runtime.Messages;
Expand All @@ -31,7 +32,6 @@
import io.quarkus.bootstrap.runner.QuarkusEntryPoint;
import io.quarkus.bootstrap.runner.RunnerClassLoader;

import io.quarkus.runtime.configuration.ProfileManager;
import io.smallrye.config.ConfigValue;
import picocli.CommandLine;
import picocli.CommandLine.Command;
Expand Down Expand Up @@ -131,7 +131,7 @@ private void beforeReaugmentationOnWindows() {
}

private void cleanTempResources() {
if (!ProfileManager.getLaunchMode().isDevOrTest()) {
if (!LaunchMode.current().isDevOrTest()) {
// only needed for dev/testing purposes
getHomePath().resolve("quarkus-artifact.properties").toFile().delete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.function.Consumer;
import java.util.regex.Pattern;

import io.smallrye.config.ConfigValue;
import io.smallrye.config.PropertiesConfigSource;

import org.keycloak.quarkus.runtime.cli.command.Main;
Expand Down Expand Up @@ -91,15 +92,14 @@ private static String getRawConfigArgs() {
}

@Override
public String getValue(String propertyName) {
Map<String, String> properties = getProperties();
String value = properties.get(propertyName);
public ConfigValue getConfigValue(String propertyName) {
ConfigValue value = super.getConfigValue(propertyName);

if (value != null) {
return value;
}

return properties.get(propertyName.replace(OPTION_PART_SEPARATOR_CHAR, '.'));
return super.getConfigValue(propertyName.replace(OPTION_PART_SEPARATOR_CHAR, '.'));
}

private static Map<String, String> parseArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,21 @@ protected String[] getFileExtensions() {

@Override
protected ConfigSource loadConfigSource(URL url, int ordinal) throws IOException {
return new PropertiesConfigSource(transform(ConfigSourceUtil.urlToMap(url)), url.toString(), ordinal);
// a workaround for https://github.com/smallrye/smallrye-config/issues/1207
// replace by the following line when fixed:
// return new PropertiesConfigSource(transform(ConfigSourceUtil.urlToMap(url)), url.toString(), ordinal);
var cs = new PropertiesConfigSource(transform(ConfigSourceUtil.urlToMap(url)), url.toString(), ordinal) {
private String name;
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
};
cs.setName(url.toString());
return cs;
}

public static class InClassPath extends KeycloakPropertiesConfigSource implements ConfigSourceProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import io.smallrye.config.ConfigValue;
import io.smallrye.config.PropertiesConfigSource;
import org.keycloak.quarkus.runtime.Environment;

Expand All @@ -54,7 +55,7 @@ public final class PersistedConfigSource extends PropertiesConfigSource {
private static final ThreadLocal<Boolean> ENABLED = ThreadLocal.withInitial(() -> true);

private PersistedConfigSource() {
super(readProperties(), "", 200);
super(readProperties(), NAME, 200);
}

public static PersistedConfigSource getInstance() {
Expand All @@ -67,15 +68,15 @@ public String getName() {
}

@Override
public String getValue(String propertyName) {
public ConfigValue getConfigValue(String propertyName) {
if (isEnabled()) {
String value = super.getValue(propertyName);
ConfigValue value = super.getConfigValue(propertyName);

if (value != null) {
return value;
}

return super.getValue(propertyName.replace(Configuration.OPTION_PART_SEPARATOR_CHAR, '.'));
return super.getConfigValue(propertyName.replace(Configuration.OPTION_PART_SEPARATOR_CHAR, '.'));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public static boolean isSameSource(ConfigValue value) {
return false;
}

return NAME.equals(value.getConfigSourceName());
// workaround for https://github.com/smallrye/smallrye-config/issues/1207
// replace by the following line when fixed:
// return NAME.equals(value.getConfigSourceName());
return value.getConfigSourceName() != null && value.getConfigSourceName().endsWith(FILE_NAME);
}

public static Path getConfigurationFile() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.keycloak.quarkus.runtime.configuration.mappers;

import io.quarkus.vertx.http.runtime.CertificateConfig;
import io.quarkus.vertx.http.runtime.options.TlsUtils;
import io.smallrye.config.ConfigSourceInterceptorContext;

import org.keycloak.common.crypto.FipsMode;
Expand All @@ -11,6 +13,7 @@
import org.keycloak.quarkus.runtime.configuration.Configuration;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -127,6 +130,52 @@ public static PropertyMapper<?>[] getHttpPropertyMappers() {

public static void validateConfig() {
boolean enabled = isHttpEnabled(Configuration.getOptionalKcValue(HttpOptions.HTTP_ENABLED.getKey()));
boolean trustStoreFile = Configuration.getOptionalKcValue(HttpOptions.HTTPS_TRUST_STORE_FILE.getKey()).isPresent();
boolean keyStoreFile = Configuration.getOptionalKcValue(HttpOptions.HTTPS_KEY_STORE_FILE.getKey()).isPresent();

if (trustStoreFile) {
CertificateConfig config = new CertificateConfig();

config.trustStoreFile = Configuration.getOptionalKcValue(HttpOptions.HTTPS_TRUST_STORE_FILE.getKey()).map(Paths::get);
config.trustStorePassword = Configuration.getOptionalKcValue(HttpOptions.HTTPS_TRUST_STORE_PASSWORD.getKey());
config.trustStoreFileType = Configuration.getOptionalKcValue(HttpOptions.HTTPS_TRUST_STORE_TYPE.getKey());
config.trustStoreProvider = Configuration.getOptionalValue("quarkus.http.ssl.certificate.trust-store-provider");
config.trustStoreCertAlias = Configuration.getOptionalValue("quarkus.http.ssl.certificate.trust-store-cert-alias");
config.trustStoreFiles = Optional.empty();

try {
TlsUtils.computeTrustOptions(config, config.trustStorePassword);
} catch (IOException e) {
throw new PropertyException(Messages.httpsConfigurationNotSet());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unable to determine 'https-trust-store-type' automatically. " +
"Adjust the file extension or specify the property.");
}
}

if (keyStoreFile) {
CertificateConfig config = new CertificateConfig();

config.keyStoreFile = Configuration.getOptionalKcValue(HttpOptions.HTTPS_KEY_STORE_FILE.getKey()).map(Paths::get);
config.keyStorePassword = Configuration.getOptionalKcValue(HttpOptions.HTTPS_KEY_STORE_PASSWORD.getKey());
config.keyStoreFileType = Configuration.getOptionalKcValue(HttpOptions.HTTPS_KEY_STORE_TYPE.getKey());
config.keyStoreProvider = Configuration.getOptionalValue("quarkus.http.ssl.certificate.key-store-provider");
config.keyStoreAlias = Configuration.getOptionalValue("quarkus.http.ssl.certificate.key-store-alias");
config.keyStoreAliasPassword = Configuration.getOptionalValue("quarkus.http.ssl.certificate.key-store-alias-password");
config.keyStoreAliasPasswordKey = Configuration.getOptionalValue("quarkus.http.ssl.certificate.key-store-alias-password-key");
config.keyStoreKeyAlias = Configuration.getOptionalValue("quarkus.http.ssl.certificate.key-store-key-alias");
config.keyFiles = Optional.empty();
config.files = Optional.empty();

try {
TlsUtils.computeKeyStoreOptions(config, config.keyStorePassword, config.keyStoreAliasPassword);
} catch (IOException e) {
throw new PropertyException(Messages.httpsConfigurationNotSet());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unable to determine 'https-key-store-type' automatically. " +
"Adjust the file extension or specify the property.");
}
}

if (!enabled) {
Optional<String> value = Configuration.getOptionalKcValue(HttpOptions.HTTPS_CERTIFICATE_FILE.getKey());
Expand Down
2 changes: 1 addition & 1 deletion quarkus/runtime/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ quarkus.transaction-manager.default-transaction-timeout=300
quarkus.arc.ignored-split-packages=org.keycloak.*

# No need to generate dependencies list
quarkus.package.include-dependency-list=false
quarkus.package.jar.include-dependency-list=false

# we do not want running dev services in distribution
quarkus.devservices.enabled=false
Expand Down
4 changes: 2 additions & 2 deletions quarkus/server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Inherit all configuration from the default runtime settings and sets those specific to the distribution

quarkus.package.output-name=keycloak
quarkus.package.type=mutable-jar
quarkus.package.jar.type=mutable-jar
quarkus.package.output-directory=lib
quarkus.package.user-providers-directory=../providers
quarkus.package.jar.user-providers-directory=../providers
quarkus.package.main-class=keycloak
1 change: 1 addition & 0 deletions quarkus/tests/integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<argLine>-Djdk.net.hosts.file=${project.build.testOutputDirectory}/hosts_file -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError --add-opens=java.base/java.security=ALL-UNNAMED -Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory</argLine>
<systemPropertyVariables>
<kc.quarkus.tests.dist>${kc.quarkus.tests.dist}</kc.quarkus.tests.dist>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
Loading

0 comments on commit a88f0a5

Please sign in to comment.