From 7f132986bb953624865bc650561b0934fd78b17a Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 20 Sep 2022 12:35:07 +0300 Subject: [PATCH 1/3] Drop "deployment" dependency on org.graalvm.nativeimage.impl package Resolves errors like: ``` [error]: Build step io.quarkus.deployment.steps.NativeImageFeatureStep#generateFeature threw an exception: java.lang.IllegalAccessError: class io.quarkus.deployment.steps.NativeImageFeatureStep (in unnamed module @0x53fa18a5) cannot access class org.graalvm.nativeimage.impl.ConfigurationCondition (in module org.graalvm.sdk) because module org.graalvm.sdk does not export org.graalvm.nativeimage.impl to unnamed module @0x53fa18a5 ``` Note that this is a temporary work-around until the reliance on `org.graalvm.nativeimage.impl` is completely dropped in favour of using public APIs only. (cherry picked from commit e9133ed9e81573a35310e0309c703e58cad8cf0e) --- .../deployment/steps/NativeImageFeatureStep.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java index 76d41d7d96c37..01786ec5bca51 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java @@ -19,7 +19,6 @@ import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import org.graalvm.nativeimage.hosted.RuntimeReflection; -import org.graalvm.nativeimage.impl.ConfigurationCondition; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -76,14 +75,15 @@ public class NativeImageFeatureStep { "org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport", "rerunInitialization", void.class, Class.class, String.class); + public static final String CONFIGURATION_CONDITION = "org.graalvm.nativeimage.impl.ConfigurationCondition"; private static final MethodDescriptor CONFIGURATION_ALWAYS_TRUE = ofMethod( - "org.graalvm.nativeimage.impl.ConfigurationCondition", - "alwaysTrue", "org.graalvm.nativeimage.impl.ConfigurationCondition"); + CONFIGURATION_CONDITION, + "alwaysTrue", CONFIGURATION_CONDITION); private static final MethodDescriptor REGISTER_LAMBDA_CAPTURING_CLASS = ofMethod( "org.graalvm.nativeimage.impl.RuntimeSerializationSupport", "registerLambdaCapturingClass", void.class, - "org.graalvm.nativeimage.impl.ConfigurationCondition", + CONFIGURATION_CONDITION, String.class); private static final MethodDescriptor LOOKUP_METHOD = ofMethod( @@ -311,7 +311,7 @@ public void write(String s, byte[] bytes) { TryBlock tc = overallCatch.tryBlock(); - ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(ConfigurationCondition.class), + ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(CONFIGURATION_CONDITION), tc.loadClassFromTCCL(String.class)); AssignableResultHandle resourcesArgs = tc.createVariable(Object[].class); tc.assign(resourcesArgs, @@ -387,7 +387,7 @@ public void write(String s, byte[] bytes) { ResultHandle runtimeResourceSupportClass = greaterThan22_2.loadClassFromTCCL(RUNTIME_RESOURCE_SUPPORT); ResultHandle addResourceBundlesParams = greaterThan22_2.marshalAsArray(Class.class, - greaterThan22_2.loadClassFromTCCL(ConfigurationCondition.class), + greaterThan22_2.loadClassFromTCCL(CONFIGURATION_CONDITION), greaterThan22_2.loadClassFromTCCL(String.class)); ResultHandle addResourceBundlesMethod = greaterThan22_2.invokeStaticMethod( LOOKUP_METHOD, From dfe3cee50c97e4ca1ccbbf34bac23691f25443fc Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Tue, 20 Sep 2022 18:24:12 +0100 Subject: [PATCH 2/3] Remove leftover error messages from CSRF Reactive filter (cherry picked from commit 32c495196f94233f1fd55a8906e84f2b9d0b2f62) --- .../reactive/runtime/CsrfRequestResponseReactiveFilter.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/extensions/csrf-reactive/runtime/src/main/java/io/quarkus/csrf/reactive/runtime/CsrfRequestResponseReactiveFilter.java b/extensions/csrf-reactive/runtime/src/main/java/io/quarkus/csrf/reactive/runtime/CsrfRequestResponseReactiveFilter.java index 9b2d32e280c64..18437548da0e5 100644 --- a/extensions/csrf-reactive/runtime/src/main/java/io/quarkus/csrf/reactive/runtime/CsrfRequestResponseReactiveFilter.java +++ b/extensions/csrf-reactive/runtime/src/main/java/io/quarkus/csrf/reactive/runtime/CsrfRequestResponseReactiveFilter.java @@ -197,8 +197,6 @@ private String getCookieToken(RoutingContext routing, CsrfReactiveConfig config) } private boolean isCsrfTokenRequired(RoutingContext routing, CsrfReactiveConfig config) { - LOG.error("**************Request path: " + routing.request().path()); - LOG.error("**************Token path: " + config.createTokenPath.get()); return config.createTokenPath.isPresent() ? config.createTokenPath.get().equals(routing.request().path()) : true; } From aa1c56a791ca3d67e361247c2d0ce8b8ede0de9b Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Tue, 20 Sep 2022 17:08:12 +0100 Subject: [PATCH 3/3] Allow to change Keycloak start command and show its logs (cherry picked from commit b3bc2337ae29fa13f5c9f4c470ec8f49a794507f) --- .../keycloak/DevServicesConfig.java | 14 ++++++++++++++ .../keycloak/KeycloakDevServicesProcessor.java | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java index 27590f08142b4..c8457325b2dd2 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java @@ -89,6 +89,20 @@ public class DevServicesConfig { @ConfigItem public Optional javaOpts; + /** + * Show Keycloak log messages with a "Keycloak:" prefix. + */ + @ConfigItem(defaultValue = "false") + public boolean showLogs; + + /** + * Keycloak start command. + * Use this property to experiment with Keycloak start options, see {@link https://www.keycloak.org/server/all-config}. + * Note it will be ignored when loading legacy Keycloak WildFly images. + */ + @ConfigItem + public Optional startCommand; + /** * The Keycloak realm name. * This property will be used to create the realm if the realm file pointed to by the 'realm-path' property does not exist, diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index 817a1a5b20697..5a11fad2a485c 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -334,7 +334,9 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild capturedDevServicesConfiguration.realmPath, capturedDevServicesConfiguration.serviceName, capturedDevServicesConfiguration.shared, - capturedDevServicesConfiguration.javaOpts); + capturedDevServicesConfiguration.javaOpts, + capturedDevServicesConfiguration.startCommand, + capturedDevServicesConfiguration.showLogs); timeout.ifPresent(oidcContainer::withStartupTimeout); oidcContainer.start(); @@ -383,10 +385,12 @@ private static class QuarkusOidcContainer extends GenericContainer startCommand; + private final boolean showLogs; public QuarkusOidcContainer(DockerImageName dockerImageName, OptionalInt fixedExposedPort, boolean useSharedNetwork, Optional realmPath, String containerLabelValue, - boolean sharedContainer, Optional javaOpts) { + boolean sharedContainer, Optional javaOpts, Optional startCommand, boolean showLogs) { super(dockerImageName); this.useSharedNetwork = useSharedNetwork; @@ -404,6 +408,8 @@ public QuarkusOidcContainer(DockerImageName dockerImageName, OptionalInt fixedEx } this.fixedExposedPort = fixedExposedPort; + this.startCommand = startCommand; + this.showLogs = showLogs; } @Override @@ -436,7 +442,7 @@ protected void configure() { if (keycloakX) { addEnv(KEYCLOAK_QUARKUS_ADMIN_PROP, KEYCLOAK_ADMIN_USER); addEnv(KEYCLOAK_QUARKUS_ADMIN_PASSWORD_PROP, KEYCLOAK_ADMIN_PASSWORD); - withCommand(KEYCLOAK_QUARKUS_START_CMD + withCommand(startCommand.orElse(KEYCLOAK_QUARKUS_START_CMD) + (useSharedNetwork ? " --hostname-port=" + fixedExposedPort.getAsInt() : "")); } else { addEnv(KEYCLOAK_WILDFLY_USER_PROP, KEYCLOAK_ADMIN_USER); @@ -469,6 +475,12 @@ protected void configure() { addEnv(KEYCLOAK_WILDFLY_IMPORT_PROP, KEYCLOAK_DOCKER_REALM_PATH); } + if (showLogs) { + super.withLogConsumer(t -> { + LOG.info("Keycloak: " + t.getUtf8String()); + }); + } + LOG.infof("Using %s powered Keycloak distribution", keycloakX ? "Quarkus" : "WildFly"); super.setWaitStrategy(Wait.forLogMessage(".*Keycloak.*started.*", 1)); }