keycloak-memoizeit
Changes
adapters/oidc/fuse7/pom.xml 42(+42 -0)
adapters/oidc/fuse7/undertow/pom.xml 157(+157 -0)
adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/KeycloakAuthenticatorService.java 41(+41 -0)
adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/PaxWebIntegrationService.java 137(+137 -0)
adapters/oidc/fuse7/undertow/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService 1(+1 -0)
adapters/oidc/undertow/pom.xml 42(+42 -0)
adapters/spi/undertow-adapter-spi/pom.xml 46(+45 -1)
Details
adapters/oidc/fuse7/pom.xml 42(+42 -0)
diff --git a/adapters/oidc/fuse7/pom.xml b/adapters/oidc/fuse7/pom.xml
new file mode 100644
index 0000000..d289c1f
--- /dev/null
+++ b/adapters/oidc/fuse7/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+ ~ and other contributors as indicated by the @author tags.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>keycloak-parent</artifactId>
+ <groupId>org.keycloak</groupId>
+ <version>4.0.0.Beta3-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>keycloak-fuse7-integration-pom</artifactId>
+ <packaging>pom</packaging>
+ <name>Keycloak Fuse 7.0 Integration</name>
+
+ <properties>
+ <fuse7.version>7.0.1-SNAPSHOT</fuse7.version>
+ <tomcat.version>8.0.14</tomcat.version>
+ <jetty9.version>9.4.2.v20170220</jetty9.version>
+ </properties>
+
+ <modules>
+ <module>undertow</module>
+ </modules>
+</project>
adapters/oidc/fuse7/undertow/pom.xml 157(+157 -0)
diff --git a/adapters/oidc/fuse7/undertow/pom.xml b/adapters/oidc/fuse7/undertow/pom.xml
new file mode 100644
index 0000000..3f00a8d
--- /dev/null
+++ b/adapters/oidc/fuse7/undertow/pom.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+ ~ and other contributors as indicated by the @author tags.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>keycloak-fuse7-integration-pom</artifactId>
+ <groupId>org.keycloak</groupId>
+ <version>4.0.0.Beta3-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>keycloak-pax-web-undertow</artifactId>
+ <name>Keycloak Fuse 7.0 Adapter - Undertow</name>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <keycloak.osgi.export>
+ org.keycloak.adapters.osgi.undertow.*;version="${project.version}"
+ </keycloak.osgi.export>
+ <keycloak.osgi.import>
+ !org.keycloak.adapters.osgi.undertow,
+ org.keycloak.*;version="${project.version}",
+ org.keycloak.adapters.osgi.*;version="${project.version}",
+ org.ops4j.pax.web.*;version="[3.0,8)",
+ javax.servlet.*;version="[2.5,4)";resolution:=optional,
+ org.apache.cxf.transport.http;resolution:=optional;version="[3,4)",
+ org.apache.cxf.transport.servlet;resolution:=optional;version="[3,4)",
+ io.undertow.*,
+ *;resolution:=optional
+ </keycloak.osgi.import>
+ <keycloak.osgi.fragment>org.ops4j.pax.web.pax-web-undertow</keycloak.osgi.fragment>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.enterprise</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-runtime</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-undertow</artifactId>
+ <version>3.1.11.fuse-000199-redhat-1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.undertow</groupId>
+ <artifactId>undertow-servlet</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-undertow-adapter</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.keycloak</groupId>
+ <artifactId>keycloak-osgi-adapter</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
+
+ <!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.name}</Bundle-Name>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>${keycloak.osgi.import}</Import-Package>
+ <Export-Package>${keycloak.osgi.export}</Export-Package>
+ <Fragment-Host>${keycloak.osgi.fragment}</Fragment-Host>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/KeycloakAuthenticatorService.java b/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/KeycloakAuthenticatorService.java
new file mode 100644
index 0000000..e248c7c
--- /dev/null
+++ b/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/KeycloakAuthenticatorService.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2018 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.keycloak.adapters.osgi.undertow;
+
+import org.ops4j.pax.web.service.AuthenticatorService;
+
+/**
+ *
+ * @author hmlnarik
+ */
+public class KeycloakAuthenticatorService implements AuthenticatorService {
+
+ @Override
+ public <T> T getAuthenticatorService(String method, Class<T> iface) {
+ if (method == null || iface != io.undertow.servlet.ServletExtension.class) {
+ return null;
+ }
+
+ if ("KEYCLOAK".equalsIgnoreCase(method)) {
+ return iface.cast(new org.keycloak.adapters.undertow.KeycloakServletExtension());
+ }
+
+ return null;
+ }
+
+}
diff --git a/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/PaxWebIntegrationService.java b/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/PaxWebIntegrationService.java
new file mode 100644
index 0000000..8c0ad20
--- /dev/null
+++ b/adapters/oidc/fuse7/undertow/src/main/java/org/keycloak/adapters/osgi/undertow/PaxWebIntegrationService.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.keycloak.adapters.osgi.undertow;
+
+import org.keycloak.adapters.osgi.PaxWebSecurityConstraintMapping;
+import org.jboss.logging.Logger;
+import org.ops4j.pax.web.service.WebContainer;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+import java.util.List;
+
+/**
+ * Integration with pax-web, which allows to inject custom security constraint for securing resources by Keycloak.
+ *
+ * <p>It assumes that pax-web {@link WebContainer} is used as implementation of OSGI {@link org.osgi.service.http.HttpService}, which
+ * is true in karaf/fuse environment</p>
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public class PaxWebIntegrationService {
+
+ protected static final Logger log = Logger.getLogger(PaxWebIntegrationService.class);
+
+ private BundleContext bundleContext;
+ private List<PaxWebSecurityConstraintMapping> constraintMappings;
+
+ private ServiceTracker webContainerTracker;
+ private HttpContext httpContext;
+
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public List<PaxWebSecurityConstraintMapping> getConstraintMappings() {
+ return constraintMappings;
+ }
+
+ public void setConstraintMappings(List<PaxWebSecurityConstraintMapping> constraintMappings) {
+ this.constraintMappings = constraintMappings;
+ }
+
+ protected ServiceTracker getWebContainerTracker() {
+ return webContainerTracker;
+ }
+
+ protected HttpContext getHttpContext() {
+ return httpContext;
+ }
+
+
+ public void start() {
+ ServiceTrackerCustomizer trackerCustomizer = new ServiceTrackerCustomizer() {
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ return addingWebContainerCallback(reference);
+ }
+
+ @Override
+ public void modifiedService(ServiceReference reference, Object service) {
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service) {
+ removingWebContainerCallback(reference);
+ }
+ };
+
+ webContainerTracker = new ServiceTracker(bundleContext, WebContainer.class.getName(), trackerCustomizer);
+ webContainerTracker.open();
+ }
+
+ public void stop() {
+ webContainerTracker.remove(webContainerTracker.getServiceReference());
+ }
+
+ protected WebContainer addingWebContainerCallback(ServiceReference webContainerServiceReference) {
+ WebContainer service = (WebContainer) bundleContext.getService(webContainerServiceReference);
+ httpContext = service.createDefaultHttpContext();
+
+ if (constraintMappings == null) {
+ throw new IllegalStateException("constraintMappings was null!");
+ }
+ for (PaxWebSecurityConstraintMapping constraintMapping : constraintMappings) {
+ addConstraintMapping(service, constraintMapping);
+ }
+
+ service.registerLoginConfig("KEYCLOAK", "specified-in-keycloak-json", null, null, httpContext);
+
+ return service;
+ }
+
+ protected void addConstraintMapping(WebContainer service, PaxWebSecurityConstraintMapping cm) {
+ log.debug("Adding security constraint name=" + cm.getConstraintName() + ", url=" + cm.getUrl() + ", dataConstraint=" + cm.getDataConstraint() + ", canAuthenticate="
+ + cm.isAuthentication() + ", roles=" + cm.getRoles());
+ service.registerConstraintMapping(
+ cm.getConstraintName(),
+ cm.getMapping(),
+ cm.getUrl(),
+ cm.getDataConstraint(),
+ cm.isAuthentication(),
+ cm.getRoles(),
+ httpContext
+ );
+ }
+
+ protected void removingWebContainerCallback(ServiceReference serviceReference) {
+ WebContainer service = (WebContainer)bundleContext.getService(serviceReference);
+ if (service != null) {
+ service.unregisterLoginConfig(httpContext);
+ service.unregisterConstraintMapping(httpContext);
+ }
+ }
+}
\ No newline at end of file
diff --git a/adapters/oidc/fuse7/undertow/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService b/adapters/oidc/fuse7/undertow/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService
new file mode 100644
index 0000000..969a4f0
--- /dev/null
+++ b/adapters/oidc/fuse7/undertow/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService
@@ -0,0 +1 @@
+org.keycloak.adapters.osgi.undertow.KeycloakAuthenticatorService
\ No newline at end of file
adapters/oidc/undertow/pom.xml 42(+42 -0)
diff --git a/adapters/oidc/undertow/pom.xml b/adapters/oidc/undertow/pom.xml
index daf567c..57321bf 100755
--- a/adapters/oidc/undertow/pom.xml
+++ b/adapters/oidc/undertow/pom.xml
@@ -30,6 +30,15 @@
<name>Keycloak Undertow Integration</name>
<description/>
+ <properties>
+ <keycloak.osgi.export>
+ org.keycloak.adapters.undertow.*
+ </keycloak.osgi.export>
+ <keycloak.osgi.import>
+ *;resolution:=optional
+ </keycloak.osgi.import>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
@@ -105,6 +114,39 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
+
+ <!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-ClassPath>.</Bundle-ClassPath>
+ <Bundle-Name>${project.name}</Bundle-Name>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>${keycloak.osgi.import}</Import-Package>
+ <Export-Package>${keycloak.osgi.export}</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
adapters/spi/undertow-adapter-spi/pom.xml 46(+45 -1)
diff --git a/adapters/spi/undertow-adapter-spi/pom.xml b/adapters/spi/undertow-adapter-spi/pom.xml
index 63ab78b..a928702 100755
--- a/adapters/spi/undertow-adapter-spi/pom.xml
+++ b/adapters/spi/undertow-adapter-spi/pom.xml
@@ -27,9 +27,19 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>keycloak-undertow-adapter-spi</artifactId>
- <name>Keycloak Undertow Integration</name>
+ <name>Keycloak Undertow Integration SPI</name>
<description/>
+ <properties>
+ <keycloak.osgi.export>
+ org.keycloak.adapters.undertow.*
+ </keycloak.osgi.export>
+ <keycloak.osgi.import>
+ *;resolution:=optional
+ </keycloak.osgi.import>
+ <keycloak.osgi.fragment>${project.groupId}.keycloak-undertow-adapter</keycloak.osgi.fragment>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
@@ -76,6 +86,40 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
+
+ <!-- Adding OSGI metadata to the JAR without changing the packaging type. -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-ClassPath>.</Bundle-ClassPath>
+ <Bundle-Name>${project.name}</Bundle-Name>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>${keycloak.osgi.import}</Import-Package>
+ <Export-Package>${keycloak.osgi.export}</Export-Package>
+ <Fragment-Host>${keycloak.osgi.fragment}</Fragment-Host>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/distribution/adapters/osgi/features/src/main/resources/features.xml b/distribution/adapters/osgi/features/src/main/resources/features.xml
index f3dc3e9..00207f3 100755
--- a/distribution/adapters/osgi/features/src/main/resources/features.xml
+++ b/distribution/adapters/osgi/features/src/main/resources/features.xml
@@ -40,7 +40,7 @@
<feature name="keycloak-osgi-adapter" version="${project.version}" resolver="(obr)">
<details>The keycloak adapter core stuff</details>
<feature>keycloak-adapter-core</feature>
- <feature version="[2.3,4)">http-whiteboard</feature>
+ <feature version="[2.3,8)">http-whiteboard</feature>
<bundle>mvn:org.keycloak/keycloak-osgi-adapter/${project.version}</bundle>
</feature>
@@ -54,14 +54,24 @@
</feature>
<feature name="keycloak-jetty9-adapter" version="${project.version}" resolver="(obr)">
- <details>The keycloak Jetty9 adapter</details>
+ <details>The keycloak Jetty 9.2 adapter (Fuse 6.3)</details>
<feature>keycloak-adapter-core</feature>
- <feature version="[9,10)">jetty</feature>
+ <feature version="[9.2,9.3)">jetty</feature>
<bundle>mvn:org.keycloak/keycloak-jetty-adapter-spi/${project.version}</bundle>
<bundle>mvn:org.keycloak/keycloak-jetty-core/${project.version}</bundle>
<bundle>mvn:org.keycloak/keycloak-jetty92-adapter/${project.version}</bundle>
</feature>
+ <!-- Keycloak adapter for PaxWeb undertow provider -->
+ <feature name="keycloak-pax-http-undertow" version="${project.version}">
+ <details>Keycloak Pax-Web adapter for Undertow</details>
+ <feature>keycloak-osgi-adapter</feature>
+ <feature>keycloak-adapter-core</feature>
+ <bundle>mvn:org.keycloak/keycloak-undertow-adapter/${project.version}</bundle>
+ <bundle>mvn:org.keycloak/keycloak-undertow-adapter-spi/${project.version}</bundle>
+ <bundle>mvn:org.keycloak/keycloak-pax-web-undertow/${project.version}</bundle>
+ </feature>
+
<feature name="keycloak-jaas" version="${project.version}" resolver="(obr)">
<details>The keycloak JAAS configuration</details>
<feature>keycloak-adapter-core</feature>