Skip to content

Commit

Permalink
Add support for MicroProfile JWT
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed Nov 9, 2022
1 parent bd0ecc3 commit 938e198
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 5 deletions.
4 changes: 4 additions & 0 deletions appserver/distributions/glassfish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
basedir="${patches}/xmlsec" includes="META-INF/MANIFEST.MF"
destfile="${glassfish.modules}/xmlsec.jar"
/>
<jarupdate
basedir="${patches}/microprofile-jwt-auth-api" includes="META-INF/MANIFEST.MF"
destfile="${glassfish.modules}/microprofile-jwt-auth-api.jar"
/>
</target>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Manifest-Version: 1.0
Bundle-Description: MicroProfile Parent POM
Bundle-License: Apache License, Version 2.0
Bundle-SymbolicName: org.eclipse.microprofile.jwt
Bnd-LastModified: 1637150061577
Bundle-ManifestVersion: 2
Bundle-DocURL: https://github.com/eclipse/microprofile-jwt-auth/microp
rofile-jwt-auth-api
Bundle-Vendor: Eclipse Foundation
Import-Package: jakarta.enterprise.util;version="[3.0,5)",jakarta.inje
ct;version="[2.0,3)",jakarta.json;version="[2.0,3)"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Bundle-Developers: starksm64;name="Scott M Stark";organization="Red Ha
t Inc.";organizationUrl="https://redhat.com",dblevins;name="David Ble
vins";organization=Tomitribe;organizationUrl="https://tomitribe.com",
sberyozkin;name="Sergey Beryozkin1";organization="Red Hat Inc.";organ
izationUrl="https://redhat.com",radcortez;name="Roberto Cortez";organ
ization="Red Hat Inc.";organizationUrl="https://redhat.com",rdebussch
er;name="Rudy De Busscher";organization=Payara;organizationUrl="https
://www.payara.fish/",ayoho;name="Adam Yoho";organization=IBM;organiza
tionUrl="https://www.ibm.com",teddyjtorres;name="Teddy Torres";organi
zation=IBM;organizationUrl="https://www.ibm.com"
Tool: Bnd-5.2.0.202010142003
Export-Package: org.eclipse.microprofile.auth;version="1.0",org.eclips
e.microprofile.jwt;version="2.0";uses:="jakarta.enterprise.util,jakar
ta.inject",org.eclipse.microprofile.jwt.config;version="2.0.0"
Bundle-Name: MicroProfile JWT Auth Bundle
Bundle-Version: 2.0.0
Bundle-SCM: url="https://github.com/eclipse/microprofile-jwt-auth/micr
oprofile-jwt-auth-api",connection="scm:git:https://github.com/eclipse
/microprofile-jwt-auth.git/microprofile-jwt-auth-api",developer-conne
ction="scm:git:git@github.com:eclipse/microprofile-jwt-auth.git/micro
profile-jwt-auth-api",tag="2.0"
Build-Jdk-Spec: 1.8
Created-By: 1.8.0_292 (AdoptOpenJDK)

24 changes: 23 additions & 1 deletion appserver/featuresets/glassfish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@
<activation>
<jdk>[17,)</jdk>
</activation>
<dependencies>
<dependencies>
<!-- MicroProfile Glassfish Connectors -->
<dependency>
<groupId>org.glassfish.main.microprofile</groupId>
Expand Down Expand Up @@ -843,6 +843,28 @@
</exclusion>
</exclusions>
</dependency>

<!-- MicroProfile JWT -->
<dependency>
<groupId>org.eclipse.microprofile.jwt</groupId>
<artifactId>microprofile-jwt-auth-api</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>microprofile-jwt-auth</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</profile>
</profiles>
Expand Down
27 changes: 23 additions & 4 deletions appserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@
<!-- MicroProfile Config -->
<microprofile.config-api.version>3.0.2</microprofile.config-api.version>
<helidon-config.version>3.0.2</helidon-config.version>

<!-- MicroProfile JWT / JWT Authentication Mechanism for Jakarta Security -->
<microprofile-jwt-auth-api.version>2.0</microprofile-jwt-auth-api.version>
<omnifaces-jwt-auth.version>2.0.1-SNAPSHOT</omnifaces-jwt-auth.version>



<!-- Admin console components -->

Expand Down Expand Up @@ -644,16 +650,29 @@
<artifactId>schema2beans</artifactId>
<version>${schema2beans.version}</version>
</dependency>


<!-- MicroProfile Config -->
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>${microprofile.config-api.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.config</groupId>
<artifactId>helidon-microprofile-config</artifactId>
<version>${helidon-config.version}</version>
</dependency>

<!-- MicroProfile JWT -->
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>${microprofile.config-api.version}</version>
<groupId>org.eclipse.microprofile.jwt</groupId>
<artifactId>microprofile-jwt-auth-api</artifactId>
<version>${microprofile-jwt-auth-api.version}</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>microprofile-jwt-auth</artifactId>
<version>${omnifaces-jwt-auth.version}</version>
</dependency>

<!-- Other -->
Expand Down
179 changes: 179 additions & 0 deletions appserver/tests/tck/jwt/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<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>
<groupId>org.glassfish.main.tests.tck</groupId>
<artifactId>tck</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>

<artifactId>glassfish-external-tck-microprofile-jwt</artifactId>

<name>TCK: JWT</name>
<description>Aggregates dependencies and runs the MicroProfile JWT TCK</description>

<properties>
<maven.compiler.release>17</maven.compiler.release>

<glassfish.version>${project.version}</glassfish.version>
<glassfish.root>${project.build.directory}</glassfish.root>
<glassfish.home>${glassfish.root}/glassfish7</glassfish.home>
</properties>

<dependencies>
<!--
This is the MP-JWT TCK base extension and utility classes
archive.
-->
<dependency>
<groupId>org.eclipse.microprofile.jwt</groupId>
<artifactId>microprofile-jwt-auth-tck</artifactId>
<version>2.0</version>
</dependency>

<!--
This is the actual MP-JWT TCK test classes archive
-->
<dependency>
<groupId>org.eclipse.microprofile.jwt</groupId>
<artifactId>microprofile-jwt-auth-tck</artifactId>
<version>2.0</version>
<type>test-jar</type>
</dependency>

<!--
The Arquillian connector used to start/stop GlassFish and deploy
archives to it.
-->
<dependency>
<groupId>org.omnifaces.arquillian</groupId>
<artifactId>arquillian-glassfish-server-managed</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>

<!--
Jakarta EE 10 client implementations. This is needed as the unit
tests make use of Jakarta EE 10 client APIs, but do not specify the
implementation.
-->
<dependency>
<groupId>org.omnifaces.arquillian</groupId>
<artifactId>glassfish-client-ee10</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<!--
Extract the TCK Suite Files, so that the surefire plugin
can refer to tck-base-suite.xml
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.microprofile.jwt</groupId>
<artifactId>microprofile-jwt-auth-tck</artifactId>
<version>2.0</version>
<classifier>tests</classifier>>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/tck-suite</outputDirectory>
<!-- Include the tck-base-suite.xml file -->
<includes>**/tck-base-suite.xml</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>

<execution>
<id>unpack-glassfish</id>
<phase>test-compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<markersDirectory>${glassfish.root}/dependency-maven-plugin-markers</markersDirectory>
<artifactItems>
<artifactItem>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>${glassfish.version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${glassfish.root}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>


<!--
Run the TCK tests aginst the tck-base-suite.xml file.
Single tests can be run using the regular -Dtest paramater, e.g.
-Dtest=ClaimValueInjectionTest#verifyInjectedAudience
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<dependenciesToScan>org.eclipse.microprofile.jwt:microprofile-jwt-auth-tck</dependenciesToScan>
<suiteXmlFiles>
<suiteXmlFile>${project.build.directory}/tck-suite/suites/tck-base-suite.xml</suiteXmlFile>
</suiteXmlFiles>

<!-- System Properties -->
<systemPropertyVariables>
<glassfish.home>${glassfish.home}</glassfish.home>
<glassfish.maxHeapSize>2048m</glassfish.maxHeapSize>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.microprofile.jwt.tck;

import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.core.spi.LoadableExtension;
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.spec.WebArchive;

/**
* WebArchiveUpdater updates the web archive that is created by the JWT tests.
*
* <p>
* Specifically it corrects the properties file if needed, and adds glassfish-web.xml for the role
* mapping and context root setting.
*
* @author Arjan Tijms
*
*/
public class WebArchiveUpdater implements ApplicationArchiveProcessor, LoadableExtension {

@Override
public void register(ExtensionBuilder extensionBuilder) {
extensionBuilder.service(ApplicationArchiveProcessor.class, WebArchiveUpdater.class);
}

@Override
public void process(Archive<?> archive, TestClass testClass) {
if (archive instanceof WebArchive webArchive) {
Node metaInfConfig = webArchive.get("/META-INF/microprofile-config.properties");

if (metaInfConfig == null) {
if (webArchive.get("/WEB-INF/classes/publicKey.pem") != null) {
webArchive.addAsResource("META-INF/public-key.properties", "META-INF/microprofile-config.properties");
} else {
webArchive.addAsResource("META-INF/microprofile-config.properties");
}
} else {
webArchive.addAsResource(metaInfConfig.getAsset(), "META-INF/microprofile-config.properties");
webArchive.delete("/META-INF/microprofile-config.properties");
}

webArchive.addAsWebInfResource("glassfish-web.xml");

System.out.printf("WebArchive: %s\n", webArchive.toString(true));
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mp.jwt.verify.publickey.location=/publicKey.pem
mp.jwt.verify.issuer=https://server.example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.glassfish.microprofile.jwt.tck.WebArchiveUpdater

0 comments on commit 938e198

Please sign in to comment.