Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
06750c4
First working version.
rodant Mar 25, 2020
45cedce
Fix checkstyle issues.
rodant Mar 25, 2020
a0c1a8d
Some refactorings and tests.
rodant Apr 2, 2020
8e0f5b5
Added a test for other malformed JWT cases.
rodant Apr 3, 2020
31a9099
Small fixes.
rodant Apr 3, 2020
2c20818
extract key definition.
rodant Apr 4, 2020
4ba691f
extract headers definition.
rodant Apr 4, 2020
bb54805
Refactor tests.
rodant Apr 4, 2020
1c451a8
Fix checkstyle issues.
rodant Apr 4, 2020
2c19d7a
Removed redundant logs in case of throwing JWT exception.
rodant Apr 8, 2020
3a71dc8
Small massage improvements.
rodant Apr 8, 2020
29eb879
Better error handling and a test.
rodant Apr 8, 2020
1637631
Fix for checkstyle.
rodant Apr 8, 2020
4f2c96f
Rename the authenticator for Solid.
rodant Apr 9, 2020
a7dd0be
Introduce own exception for malformed JWTs.
rodant Apr 9, 2020
4e74347
Fix checkstyle errors.
rodant Apr 9, 2020
6333386
Implement the Solid webId provider confirmation.
rodant Apr 10, 2020
423dcad
Fix checkstyle issue.
rodant Apr 10, 2020
f7648b4
Fix checkstyle issues.
rodant Apr 10, 2020
0ff6b84
Fixes concerning review comments, refactoring.
rodant Apr 10, 2020
4bdcd0e
Make the WebId-OIDC option explicitly configurable.
rodant Apr 14, 2020
2d0e49f
Rename the authenticator for WebId-OIDC.
rodant Apr 14, 2020
3bc75c3
Improve error responses for constraint violations (#793)
acoburn Apr 20, 2020
e68be2e
Use platform for quarkus (#794)
acoburn Apr 21, 2020
e15d4b8
Implement the proof of possession.
rodant Apr 21, 2020
a5d4bc8
Fix the build.
rodant Apr 21, 2020
1d5b15b
Bump netty to 4.1.48.Final (#796)
acoburn Apr 21, 2020
eddf16c
Update smallrye-config to 1.7.0 (#797)
acoburn Apr 22, 2020
13c940b
Add configuration to enable/disable LDP model changes (#799)
acoburn Apr 22, 2020
d059b60
Support externalized default root ACL resources (#798)
acoburn Apr 22, 2020
e7fa5e6
Bump microprofile-metrics-api from 2.3 to 2.3.1 (#800)
dependabot-preview[bot] Apr 23, 2020
d725cad
Bump netty-bom from 4.1.48.Final to 4.1.49.Final (#801)
dependabot-preview[bot] Apr 23, 2020
adf7681
Update license URL
acoburn Apr 23, 2020
96ca6ac
Add license distribution field for POM generation
acoburn Apr 23, 2020
7c1a555
Use SPDX for license name
acoburn Apr 23, 2020
41f7ce6
Remove redundant version declaration
acoburn Apr 23, 2020
4a7fb03
[Gradle Release Plugin] - pre tag commit: 'trellis-0.11.2'.
acoburn Apr 23, 2020
44ea039
[Gradle Release Plugin] - new version commit: 'trellis-0.12.0-SNAPSH…
acoburn Apr 23, 2020
962e739
Bump quarkus-bom from 1.3.2.Final to 1.4.0.Final (#802)
dependabot-preview[bot] Apr 24, 2020
19ec82a
Upgrade pitest components (#804)
acoburn Apr 24, 2020
4b4af0c
Bump jacksonVersion from 2.10.3 to 2.11.0 (#805)
dependabot-preview[bot] Apr 27, 2020
011dc1d
Check signature of the id token too.
rodant Apr 27, 2020
6de707d
Bump quarkus-bom from 1.4.0.Final to 1.4.1.Final (#806)
dependabot-preview[bot] Apr 27, 2020
b4b04d8
Use GCache for the provider keys.
rodant Apr 27, 2020
479657c
Fis build for Java modules.
rodant Apr 27, 2020
667421f
Bump jaxb-runtime from 2.3.2 to 2.3.3 (#807)
dependabot-preview[bot] Apr 28, 2020
37d5112
Add license download configuration (#808)
acoburn Apr 28, 2020
4fb4a1e
Add copyright statement to source headers
acoburn Apr 28, 2020
2b976f3
Adjust license headers for module-info files
acoburn Apr 28, 2020
085b8fa
Fix build for OSGI and rename method.
rodant Apr 29, 2020
9ae14b2
Check nullity of issuer claim before fetching keys.
rodant Apr 29, 2020
659ac5e
Bump jakarta.inject-api from 1.0 to 1.0.1 (#809)
dependabot-preview[bot] Apr 29, 2020
a5bd85f
Fetch jwks_uri from OIDC configuration endpoint.
rodant Apr 29, 2020
bbbb517
Use key resolver for building the JWT parser.
rodant Apr 29, 2020
b9c0527
Use key resolver also for building the external JWT parser.
rodant Apr 29, 2020
f130345
Introduce some constants for standard claims.
rodant Apr 29, 2020
639a0f3
Bump smallrye-health from 2.2.0 to 2.2.1 (#811)
dependabot-preview[bot] Apr 30, 2020
d9f085d
Adjust copyright license year (#812)
acoburn May 1, 2020
cd39205
Bump dropwizardVersion from 2.0.8 to 2.0.9 (#813)
dependabot-preview[bot] May 4, 2020
28db430
Check the token pop type.
rodant May 4, 2020
100e499
Check issuer id-token's audience match.
rodant May 4, 2020
d0f0c4c
Make cache size and expiration time configurable.
rodant May 4, 2020
c1df473
Fix the failing test.
rodant May 4, 2020
ce68d77
Bump quarkus-bom from 1.4.1.Final to 1.4.2.Final (#815)
dependabot-preview[bot] May 6, 2020
5863aeb
Rework quarkus build structure (#816)
acoburn May 7, 2020
bebc444
Improvements after code review.
rodant May 7, 2020
cb7a117
Use string#format for a parametrized message to output the stack trac…
rodant May 7, 2020
c02c638
Merge branch 'master' into oauth-nss-id-token-support
rodant May 7, 2020
0af42f3
Fix Licence headers and code style issues.
rodant May 7, 2020
f8aef0b
Fix more code style issues.
rodant May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion auth/basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
testRuntimeOnly "jakarta.activation:jakarta.activation-api:$activationApiVersion"

testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
testImplementation "io.smallrye:smallrye-config:$smallryeConfigVersion"
testImplementation "io.smallrye.config:smallrye-config:$smallryeConfigVersion"
testImplementation "org.glassfish.jersey.core:jersey-server:$jerseyVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
}
Expand Down
4 changes: 3 additions & 1 deletion auth/basic/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand All @@ -14,7 +16,7 @@
module org.trellisldp.auth.basic {
exports org.trellisldp.auth.basic;

requires jakarta.inject.api;
requires jakarta.inject;
requires java.ws.rs;
requires java.xml.bind;
requires java.annotation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
2 changes: 1 addition & 1 deletion auth/jwt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "org.eclipse.microprofile.config:microprofile-config-api:$microprofileConfigVersion"

testImplementation "io.smallrye:smallrye-config:$smallryeConfigVersion"
testImplementation "io.smallrye.config:smallrye-config:$smallryeConfigVersion"
testImplementation "io.smallrye:smallrye-jwt:$smallryeJwtVersion"
testImplementation "jakarta.json.bind:jakarta.json.bind-api:$jsonbApiVersion"
testImplementation "org.eclipse:yasson:$yassonVersion"
Expand Down
4 changes: 3 additions & 1 deletion auth/jwt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand All @@ -14,7 +16,7 @@
module org.trellisldp.auth.jwt {
exports org.trellisldp.auth.jwt;

requires jakarta.inject.api;
requires jakarta.inject;
requires java.ws.rs;
requires java.annotation;
requires microprofile.config.api;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
5 changes: 4 additions & 1 deletion auth/oauth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {
api "jakarta.inject:jakarta.inject-api:$injectApiVersion"
api "jakarta.annotation:jakarta.annotation-api:$annotationApiVersion"
api "jakarta.ws.rs:jakarta.ws.rs-api:$jaxrsApiVersion"
api "com.google.guava:guava:$guavaVersion"

implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
implementation "commons-io:commons-io:$commonsIoVersion"
Expand All @@ -28,10 +29,12 @@ dependencies {
testRuntimeOnly "jakarta.activation:jakarta.activation-api:$activationApiVersion"

testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
testImplementation "io.smallrye:smallrye-config:$smallryeConfigVersion"
testImplementation "io.smallrye.config:smallrye-config:$smallryeConfigVersion"
testImplementation "org.bouncycastle:bcprov-jdk15on:$bouncycastleVersion"
testImplementation "org.glassfish.jersey.core:jersey-server:$jerseyVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"

implementation project(':trellis-cache')
}

pitest {
Expand Down
5 changes: 4 additions & 1 deletion auth/oauth/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand All @@ -14,12 +16,13 @@
module org.trellisldp.auth.oauth {
exports org.trellisldp.auth.oauth;

requires jakarta.inject.api;
requires jakarta.inject;
requires java.ws.rs;
requires java.annotation;
requires jjwt.api;
requires jjwt.jackson;
requires jjwt.impl;
requires microprofile.config.api;
requires org.slf4j;
requires org.trellisldp.cache;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand All @@ -13,34 +15,18 @@
*/
package org.trellisldp.auth.oauth;

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toMap;
import static org.slf4j.LoggerFactory.getLogger;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwsHeader;
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SigningKeyResolverAdapter;
import io.jsonwebtoken.io.Deserializer;
import io.jsonwebtoken.jackson.io.JacksonDeserializer;
import io.jsonwebtoken.security.SecurityException;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URL;
import java.security.Key;
import java.util.AbstractMap.SimpleEntry;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;

/**
Expand All @@ -57,7 +43,7 @@ public class JwksAuthenticator implements Authenticator {
* @param url the location of the public jwks keys
*/
public JwksAuthenticator(final String url) {
this.keys = buildKeys(url);
this.keys = OAuthUtils.fetchKeys(url);
}

@Override
Expand All @@ -76,27 +62,4 @@ public Key resolveSigningKey(final JwsHeader header, final Claims claims) {
}
}).build().parseClaimsJws(token).getBody();
}

private static Map<String, Key> buildKeys(final String location) {
// TODO eventually, this will become part of the JJWT library
final Deserializer<Map<String, List<Map<String, String>>>> deserializer = new JacksonDeserializer<>();
try (final InputStream input = new URL(location).openConnection().getInputStream()) {
return deserializer.deserialize(IOUtils.toByteArray(input)).getOrDefault("keys", emptyList()).stream()
.map(JwksAuthenticator::buildKeyEntry).filter(Objects::nonNull).collect(collectingAndThen(
toMap(Map.Entry::getKey, Map.Entry::getValue), Collections::unmodifiableMap));
} catch (final IOException ex) {
LOGGER.error("Error fetching/parsing jwk document", ex);
}
return emptyMap();
}

private static Map.Entry<String, Key> buildKeyEntry(final Map<String, String> jwk) {
final BigInteger modulus = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.get("n")));
final BigInteger exponent = new BigInteger(1, Base64.getUrlDecoder().decode(jwk.get("e")));
final Key key = OAuthUtils.buildRSAPublicKey("RSA", modulus, exponent);
if (key != null && jwk.containsKey("kid")) {
return new SimpleEntry<>(jwk.get("kid"), key);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2020 Aaron Coburn and individual contributors
*
* 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
Expand Down
Loading