Skip to content

Commit

Permalink
Merge pull request #1569 from fjuma/ELY-2034
Browse files Browse the repository at this point in the history
[ELY-2034] Add OpenID Connect mechanism implementation
  • Loading branch information
fjuma authored Sep 10, 2021
2 parents 67e65d0 + 4b423fb commit 00b70a4
Show file tree
Hide file tree
Showing 82 changed files with 11,708 additions and 32 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
# ELY-2204 - Temporarily preventing OidcTest from running on macOS since there
# are intermittent issues with starting up the Docker container.
#- if: matrix.os == 'macos-latest'
# name: Install docker
# run: |
# brew install docker docker-machine docker-compose
# brew services start docker-machine
# docker-machine create --driver virtualbox default
# docker --version
- name: Cache Maven packages
uses: actions/cache@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions ELY_Messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@
21000 - 21999
22000 - 22499 wildfly-elytron-http-form
22500 - 22999 wildfly-elytron-http-spnego
23000 - 23999
24000 - 24999
25000 - 25999
23000 - 23999 wildfly-elytron-http-oidc
24000 - 24999 wildfly-elytron-jose-jwk
25000 - 25999 wildfly-elytron-jose-jws
26000 - 26999
27000 - 27999
28000 - 28999
Expand Down
4 changes: 2 additions & 2 deletions audit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
</dependency>

<dependency>
<groupId>org.jboss.spec.javax.json</groupId>
<artifactId>jboss-json-api_1.0_spec</artifactId>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions auth/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.json</groupId>
<artifactId>jboss-json-api_1.0_spec</artifactId>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions auth/realm/token/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.json</groupId>
<artifactId>jboss-json-api_1.0_spec</artifactId>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
4 changes: 4 additions & 0 deletions http/base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
Expand Down Expand Up @@ -282,4 +283,11 @@ default boolean resumeRequest() {
return false;
}

/**
* Set the request input stream supplier. The default implementation does nothing.
*
* @param requestInputStreamSupplier the request input stream supplier
*/
default void setRequestInputStreamSupplier(Supplier<InputStream> requestInputStreamSupplier) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import javax.net.ssl.SSLSession;

Expand Down Expand Up @@ -267,4 +268,12 @@ default String getRemoteUser() {
*/
boolean resumeRequest();

/**
* Set the request input stream supplier. The default implementation does nothing.
*
* @param requestInputStreamSupplier the request input stream supplier
*/
default void setRequestInputStreamSupplier(Supplier<InputStream> requestInputStreamSupplier) {}


}
154 changes: 154 additions & 0 deletions http/oidc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2020 Red Hat, Inc., and individual 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/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-parent</artifactId>
<version>1.17.0.CR1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>wildfly-elytron-http-oidc</artifactId>

<name>WildFly Elytron - HTTP OIDC</name>
<description>WildFly Security HTTP OIDC Mechanism Implementation</description>

<dependencies>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-auth-server</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-credential</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-http</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-jose-jwk</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-jose-util</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-mechanism</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
<artifactId>jose4j</artifactId>
</dependency>

<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron-tests</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021 Red Hat, Inc., and individual 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.wildfly.security.http.oidc;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* A representation of an OpenID Connect token response that contains both an access token
* and an ID token as per the <a href="https://openid.net/specs/openid-connect-core-1_0.html#TokenResponse">OpenID Connect Core 1.0</a>
* specification.
*
* @author <a href="mailto:[email protected]">Bill Burke</a>
* @author <a href="mailto:[email protected]">Farah Juma</a>
*/
public class AccessAndIDTokenResponse {

@JsonProperty("access_token")
protected String accessToken;

@JsonProperty("token_type")
protected String tokenType;

@JsonProperty("expires_in")
protected long expiresIn;

@JsonProperty("refresh_token")
protected String refreshToken;

@JsonProperty("id_token")
protected String idToken;

protected Map<String, Object> otherClaims = new HashMap<>();

// OIDC Financial API Read Only Profile : scope MUST be returned in the response from Token Endpoint
@JsonProperty("scope")
protected String scope;

// Keycloak-specific property
@JsonProperty("not-before-policy")
protected int notBeforePolicy;

public String getAccessToken() {
return accessToken;
}

public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}

public String getTokenType() {
return tokenType;
}

public void setTokenType(String tokenType) {
this.tokenType = tokenType;
}

public long getExpiresIn() {
return expiresIn;
}

public void setExpiresIn(long expiresIn) {
this.expiresIn = expiresIn;
}

public String getRefreshToken() {
return refreshToken;
}

public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}

public String getScope() {
return scope;
}

public void setScope(String scope) {
this.scope = scope;
}

public String getIDToken() {
return idToken;
}

public void setIDToken(String idToken) {
this.idToken = idToken;
}

public int getNotBeforePolicy() {
return notBeforePolicy;
}

public void setNotBeforePolicy(int notBeforePolicy) {
this.notBeforePolicy = notBeforePolicy;
}


@JsonAnyGetter
public Map<String, Object> getOtherClaims() {
return otherClaims;
}

@JsonAnySetter
public void setOtherClaims(String name, Object value) {
otherClaims.put(name, value);
}

}
Loading

0 comments on commit 00b70a4

Please sign in to comment.