SAML ECP does not work on the latest WF/EAP8

Fixes #24746

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
Martin Bartoš 2023-11-14 14:43:36 +01:00 committed by Alexander Schwartz
parent c22707ed67
commit fd56666334
19 changed files with 171 additions and 19 deletions

1
.gitignore vendored
View file

@ -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/

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId>
<version>999.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<name>Keycloak SAML Client Adapter Core Jakarta</name>
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
<jakarta-transformer-sources>${project.basedir}/../core/src</jakarta-transformer-sources>
<jakarta-transformer-target>${project.basedir}/src</jakarta-transformer-target>
</properties>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core-public</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-adapter-spi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-api-public</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-crypto-default</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>transform</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<java classname="org.eclipse.transformer.jakarta.JakartaTransformer">
<arg value="-o" />
<arg value="${jakarta-transformer-sources}" />
<arg value="${jakarta-transformer-target}" />
<classpath>
<pathelement path="${plugin_classpath}" />
</classpath>
</java>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.transformer</groupId>
<artifactId>org.eclipse.transformer.cli</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View file

@ -71,7 +71,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>

View file

@ -33,6 +33,7 @@
<modules>
<module>core-public</module>
<module>core</module>
<module>core-jakarta</module>
<module>jetty</module>
<module>undertow</module>
<module>tomcat</module>

View file

@ -68,7 +68,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<scope>provided</scope>
</dependency>
<dependency>

View file

@ -158,7 +158,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View file

@ -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));
}

View file

@ -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");
}
}

View file

@ -103,7 +103,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>

View file

@ -73,7 +73,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>

View file

@ -19,12 +19,12 @@
~ limitations under the License.
-->
<module xmlns="urn:jboss:module:1.3" name="org.keycloak.keycloak-saml-adapter-core">
<module xmlns="urn:jboss:module:1.3" name="org.keycloak.keycloak-saml-adapter-core-jakarta">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<artifact name="${org.keycloak:keycloak-saml-adapter-core}"/>
<artifact name="${org.keycloak:keycloak-saml-adapter-core-jakarta}"/>
</resources>
<dependencies>
<module name="javax.api"/>

View file

@ -38,7 +38,7 @@
<module name="org.keycloak.keycloak-saml-core-public"/>
<module name="org.keycloak.keycloak-saml-core"/>
<module name="org.keycloak.keycloak-saml-adapter-api-public"/>
<module name="org.keycloak.keycloak-saml-adapter-core"/>
<module name="org.keycloak.keycloak-saml-adapter-core-jakarta"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.apache.httpcomponents"/>
</dependencies>

View file

@ -38,7 +38,7 @@
<module name="org.keycloak.keycloak-saml-core-public"/>
<module name="org.keycloak.keycloak-saml-core"/>
<module name="org.keycloak.keycloak-saml-adapter-api-public"/>
<module name="org.keycloak.keycloak-saml-adapter-core"/>
<module name="org.keycloak.keycloak-saml-adapter-core-jakarta"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.apache.httpcomponents"/>
<module name="org.infinispan"/>

View file

@ -64,8 +64,8 @@
<maven-resource group="org.keycloak" artifact="keycloak-saml-adapter-api-public"/>
</module-def>
<module-def name="org.keycloak.keycloak-saml-adapter-core">
<maven-resource group="org.keycloak" artifact="keycloak-saml-adapter-core"/>
<module-def name="org.keycloak.keycloak-saml-adapter-core-jakarta">
<maven-resource group="org.keycloak" artifact="keycloak-saml-adapter-core-jakarta"/>
</module-def>
<module-def name="org.keycloak.keycloak-jboss-adapter-core">

View file

@ -106,7 +106,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>

View file

@ -19,7 +19,7 @@
~ limitations under the License.
-->
<module xmlns="urn:jboss:module:1.3" name="org.keycloak.keycloak-saml-adapter-core">
<module xmlns="urn:jboss:module:1.3" name="org.keycloak.keycloak-saml-adapter-core-jakarta">
<properties>
<property name="jboss.api" value="private"/>
</properties>

View file

@ -38,7 +38,7 @@
<module name="org.keycloak.keycloak-saml-core-public"/>
<module name="org.keycloak.keycloak-saml-core"/>
<module name="org.keycloak.keycloak-saml-adapter-api-public"/>
<module name="org.keycloak.keycloak-saml-adapter-core"/>
<module name="org.keycloak.keycloak-saml-adapter-core-jakarta"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.apache.httpcomponents"/>
</dependencies>

View file

@ -38,7 +38,7 @@
<module name="org.keycloak.keycloak-saml-core-public"/>
<module name="org.keycloak.keycloak-saml-core"/>
<module name="org.keycloak.keycloak-saml-adapter-api-public"/>
<module name="org.keycloak.keycloak-saml-adapter-core"/>
<module name="org.keycloak.keycloak-saml-adapter-core-jakarta"/>
<module name="org.keycloak.keycloak-common"/>
<module name="org.apache.httpcomponents"/>
<module name="org.infinispan"/>

View file

@ -1338,6 +1338,11 @@
<artifactId>keycloak-saml-adapter-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core-jakarta</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-tomcat-adapter-core</artifactId>