From fd56666334d49614b248effe37d87e758e27eb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Barto=C5=A1?= Date: Tue, 14 Nov 2023 14:43:36 +0100 Subject: [PATCH] SAML ECP does not work on the latest WF/EAP8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #24746 Signed-off-by: Martin Bartoš --- .gitignore | 1 + adapters/saml/core-jakarta/pom.xml | 126 ++++++++++++++++++ adapters/saml/jakarta-servlet-filter/pom.xml | 2 +- adapters/saml/pom.xml | 1 + adapters/saml/wildfly-elytron-jakarta/pom.xml | 2 +- .../wildfly/wildfly-jakarta-subsystem/pom.xml | 2 +- .../KeycloakDependencyProcessor.java | 7 +- .../KeycloakDependencyProcessorWildFly.java | 20 ++- .../saml-adapter-galleon-pack/pom.xml | 2 +- .../src/main/resources/license/licenses.xml | 2 +- .../main/module.xml | 4 +- .../main/module.xml | 2 +- .../main/module.xml | 2 +- .../wildfly-jakarta-modules/build.xml | 4 +- .../wildfly-jakarta-modules/pom.xml | 2 +- .../main/module.xml | 2 +- .../main/module.xml | 2 +- .../main/module.xml | 2 +- pom.xml | 5 + 19 files changed, 171 insertions(+), 19 deletions(-) create mode 100644 adapters/saml/core-jakarta/pom.xml rename distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/{keycloak-saml-adapter-core => keycloak-saml-adapter-core-jakarta}/main/module.xml (97%) rename distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/{keycloak-saml-adapter-core => keycloak-saml-adapter-core-jakarta}/main/module.xml (98%) diff --git a/.gitignore b/.gitignore index c5a71b5970..c684a68021 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ quarkus/data/*.db /adapters/saml/jakarta-servlet-filter/src/ /adapters/oidc/jakarta-servlet-filter/src/ /adapters/saml/wildfly-elytron-jakarta/src/ +/adapters/saml/core-jakarta/src/ /adapters/saml/wildfly/wildfly-jakarta-subsystem/src/ /.metadata/ diff --git a/adapters/saml/core-jakarta/pom.xml b/adapters/saml/core-jakarta/pom.xml new file mode 100644 index 0000000000..2b4f823421 --- /dev/null +++ b/adapters/saml/core-jakarta/pom.xml @@ -0,0 +1,126 @@ + + + 4.0.0 + + keycloak-parent + org.keycloak + 999.0.0-SNAPSHOT + ../../../pom.xml + + + keycloak-saml-adapter-core-jakarta + Keycloak SAML Client Adapter Core Jakarta + + + ${maven.build.timestamp} + yyyy-MM-dd HH:mm + + ${project.basedir}/../core/src + ${project.basedir}/src + + + + + org.keycloak + keycloak-saml-core-public + provided + + + org.keycloak + keycloak-saml-core + provided + + + org.keycloak + keycloak-adapter-spi + provided + + + org.keycloak + keycloak-saml-adapter-api-public + provided + + + org.keycloak + keycloak-common + provided + + + org.keycloak + keycloak-crypto-default + test + + + org.jboss.logging + jboss-logging + provided + + + junit + junit + test + + + org.hamcrest + hamcrest + test + + + org.apache.httpcomponents + httpclient + provided + + + + + + + maven-antrun-plugin + 3.1.0 + + + transform + initialize + + run + + + + + + + + + + + + + + + + + + + org.eclipse.transformer + org.eclipse.transformer.cli + 0.2.0 + + + ant-contrib + ant-contrib + 1.0b3 + + + ant + ant + + + + + + + + + \ No newline at end of file diff --git a/adapters/saml/jakarta-servlet-filter/pom.xml b/adapters/saml/jakarta-servlet-filter/pom.xml index f7ee0ee6bc..03b33d337b 100755 --- a/adapters/saml/jakarta-servlet-filter/pom.xml +++ b/adapters/saml/jakarta-servlet-filter/pom.xml @@ -71,7 +71,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta org.keycloak diff --git a/adapters/saml/pom.xml b/adapters/saml/pom.xml index f941cc0876..443ad2a468 100755 --- a/adapters/saml/pom.xml +++ b/adapters/saml/pom.xml @@ -33,6 +33,7 @@ core-public core + core-jakarta jetty undertow tomcat diff --git a/adapters/saml/wildfly-elytron-jakarta/pom.xml b/adapters/saml/wildfly-elytron-jakarta/pom.xml index c6b6ff388d..b3a496978e 100755 --- a/adapters/saml/wildfly-elytron-jakarta/pom.xml +++ b/adapters/saml/wildfly-elytron-jakarta/pom.xml @@ -68,7 +68,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta provided diff --git a/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml b/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml index 016a1037a8..15e52a6415 100755 --- a/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml +++ b/adapters/saml/wildfly/wildfly-jakarta-subsystem/pom.xml @@ -158,7 +158,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta ${project.version} diff --git a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessor.java b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessor.java index b837afcd6b..5fc44267b2 100755 --- a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessor.java +++ b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessor.java @@ -64,14 +64,19 @@ public abstract class KeycloakDependencyProcessor implements DeploymentUnitProce final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); + + addCoreModules(moduleSpecification, moduleLoader); addCommonModules(moduleSpecification, moduleLoader); addPlatformSpecificModules(phaseContext, moduleSpecification, moduleLoader); } + protected void addCoreModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { + moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false)); + } + private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { // ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified) moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false)); - moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_API_ADAPTER, false, false, false, false)); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false)); } diff --git a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessorWildFly.java b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessorWildFly.java index 1565fa47f6..de0b39b482 100755 --- a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessorWildFly.java +++ b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakDependencyProcessorWildFly.java @@ -33,15 +33,23 @@ import org.jboss.modules.ModuleLoader; */ public class KeycloakDependencyProcessorWildFly extends KeycloakDependencyProcessor { + private static final ModuleIdentifier KEYCLOAK_CORE_JAKARTA_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-saml-adapter-core-jakarta"); private static final ModuleIdentifier KEYCLOAK_ELYTRON_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-saml-wildfly-elytron-adapter"); private static final ModuleIdentifier KEYCLOAK_ELYTRON_JAKARTA_ADAPTER = ModuleIdentifier.create("org.keycloak.keycloak-saml-wildfly-elytron-jakarta-adapter"); + @Override + protected void addCoreModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { + if (isJakarta()) { + moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_JAKARTA_ADAPTER, false, false, false, false)); + } else { + super.addCoreModules(moduleSpecification, moduleLoader); + } + } + @Override protected void addPlatformSpecificModules(DeploymentPhaseContext phaseContext, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { if (isElytronEnabled(phaseContext)) { - ClassLoader classLoader = getClass().getClassLoader(); - String classLoaderName = (classLoader instanceof ModuleClassLoader ? ((ModuleClassLoader)classLoader).getName() : ""); - if (classLoaderName.contains("jakarta")) { + if (isJakarta()) { moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_ELYTRON_JAKARTA_ADAPTER, true, false, false, false)); } else { moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_ELYTRON_ADAPTER, true, false, false, false)); @@ -50,4 +58,10 @@ public class KeycloakDependencyProcessorWildFly extends KeycloakDependencyProces throw new RuntimeException("Legacy WildFly security layer is no longer supported by the Keycloak WildFly adapter"); } } + + private boolean isJakarta() { + ClassLoader classLoader = getClass().getClassLoader(); + String classLoaderName = (classLoader instanceof ModuleClassLoader ? ((ModuleClassLoader) classLoader).getName() : ""); + return classLoaderName.contains("jakarta"); + } } diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/pom.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/pom.xml index b88ea26a38..d46987e742 100644 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/pom.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/pom.xml @@ -103,7 +103,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta * diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/license/licenses.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/license/licenses.xml index e105fdd61f..1ff56094a1 100644 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/license/licenses.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/license/licenses.xml @@ -73,7 +73,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta Apache License 2.0 diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core/main/module.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml similarity index 97% rename from distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core/main/module.xml rename to distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml index 6048c0bf4a..0440e67ff9 100755 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core/main/module.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml @@ -19,12 +19,12 @@ ~ limitations under the License. --> - + - + diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml index 0aa94c746a..d89e36e07f 100755 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml @@ -38,7 +38,7 @@ - + diff --git a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml index 5c449c9202..a4a47421dc 100755 --- a/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml +++ b/distribution/galleon-feature-packs/saml-adapter-galleon-pack/src/main/resources/modules/system/add-ons/keycloak/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml @@ -38,7 +38,7 @@ - + diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/build.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/build.xml index 6668467207..77c7555eae 100755 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/build.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/build.xml @@ -64,8 +64,8 @@ - - + + diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml index db6047180c..634ddcbee2 100755 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/pom.xml @@ -106,7 +106,7 @@ org.keycloak - keycloak-saml-adapter-core + keycloak-saml-adapter-core-jakarta * diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core/main/module.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml similarity index 98% rename from distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core/main/module.xml rename to distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml index eb19ef5866..b053066e9a 100644 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core/main/module.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-adapter-core-jakarta/main/module.xml @@ -19,7 +19,7 @@ ~ limitations under the License. --> - + diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml index 6a380d651b..c0427427c8 100644 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-undertow-adapter/main/module.xml @@ -38,7 +38,7 @@ - + diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml index f56f0e5992..f0af445e5a 100644 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-jakarta-modules/src/main/resources/modules/org/keycloak/keycloak-saml-wildfly-elytron-jakarta-adapter/main/module.xml @@ -38,7 +38,7 @@ - + diff --git a/pom.xml b/pom.xml index 93060d115f..af7c81fb3b 100644 --- a/pom.xml +++ b/pom.xml @@ -1338,6 +1338,11 @@ keycloak-saml-adapter-core ${project.version} + + org.keycloak + keycloak-saml-adapter-core-jakarta + ${project.version} + org.keycloak keycloak-saml-tomcat-adapter-core