Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,22 @@ ext {
testInJavaVersions = [8, 11, 17, 21]
}

jacoco {
toolVersion = "0.8.13"
}


jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
// Needed because of broken gradle metadata, see https://github.com/google/guava/issues/6612#issuecomment-1614992368
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}
}

compileJava {
sourceCompatibility '1.8'
targetCompatibility '1.8'
java {
sourceCompatibility '21'
targetCompatibility '21'
}

test {
Expand All @@ -121,7 +112,7 @@ test {
}

dependencies {
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0'
implementation 'org.apache.commons:commons-lang3:3.18.0'
implementation 'com.google.guava:guava-annotations:r03'
implementation 'commons-codec:commons-codec:1.15'
Expand All @@ -133,9 +124,10 @@ dependencies {
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.64'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.mockito:mockito-core:2.8.9'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.springframework:spring-test:4.3.14.RELEASE'
testImplementation 'org.springframework:spring-test:6.0.14'
testImplementation 'org.springframework:spring-web:6.0.14'
testImplementation 'com.squareup.okhttp3:okhttp:4.11.0'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/maven-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ task('javadocJar', type: Jar, dependsOn: javadoc) {
tasks.withType(Javadoc).configureEach {
javadocTool = javaToolchains.javadocToolFor {
// Use latest JDK for javadoc generation
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 4 additions & 4 deletions src/main/java/com/auth0/AuthenticationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


/**
Expand Down Expand Up @@ -317,7 +317,7 @@ public Tokens handle(HttpServletRequest request, HttpServletResponse response) t
* when building the {@link AuthorizeUrl} that the user will be redirected to to login. Failure to do so may result
* in a broken login experience for the user.</p>
*
* @deprecated This method uses the {@link javax.servlet.http.HttpSession} for auth-based data, and is incompatible
* @deprecated This method uses the {@link jakarta.servlet.http.HttpSession} for auth-based data, and is incompatible
* with clients that are using the "id_token" or "token" responseType with browsers that enforce SameSite cookie
* restrictions. This method will be removed in version 2.0.0. Use
* {@link AuthenticationController#handle(HttpServletRequest, HttpServletResponse)} instead.
Expand All @@ -341,7 +341,7 @@ public Tokens handle(HttpServletRequest request) throws IdentityVerificationExce
* {@link AuthenticationController#handle(HttpServletRequest)} method. Failure to do so may result in a broken login
* experience for users.</p>
*
* @deprecated This method stores data in the {@link javax.servlet.http.HttpSession}, and is incompatible with clients
* @deprecated This method stores data in the {@link jakarta.servlet.http.HttpSession}, and is incompatible with clients
* that are using the "id_token" or "token" responseType with browsers that enforce SameSite cookie restrictions.
* This method will be removed in version 2.0.0. Use
* {@link AuthenticationController#buildAuthorizeUrl(HttpServletRequest, HttpServletResponse, String)} instead.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/auth0/AuthorizeUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.auth0.exception.Auth0Exception;
import com.auth0.json.auth.PushedAuthorizationResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;

import static com.auth0.IdentityVerificationException.API_ERROR;
Expand Down Expand Up @@ -39,7 +39,7 @@ public class AuthorizeUrl {
*
* Using this constructor with a non-null {@link HttpServletResponse} will store the state and nonce as
* cookies when the {@link AuthorizeUrl#build()} method is called, with the appropriate SameSite attribute depending
* on the responseType. State and nonce will also be stored in the {@link javax.servlet.http.HttpSession} as a fallback,
* on the responseType. State and nonce will also be stored in the {@link jakarta.servlet.http.HttpSession} as a fallback,
* but this behavior will be removed in a future release, and only cookies will be used.
*
* @param client the Auth0 Authentication API client
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/RandomStorage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.auth0;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

class RandomStorage extends SessionUtils {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/RequestProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.auth0.json.auth.TokenHolder;
import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/SessionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

/**
* Helper class to handle easy session key-value storage.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/auth0/TransientCookieStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.apache.commons.lang3.Validate;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/com/auth0/AuthenticationControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -392,7 +392,7 @@ public void shouldBuildAuthorizeUriWithRandomStateAndNonce() {
HttpServletRequest request = new MockHttpServletRequest();
HttpServletResponse response = new MockHttpServletResponse();

controller.buildAuthorizeUrl(request, response,"https://redirect.uri/here");
controller.buildAuthorizeUrl(request, response, "https://redirect.uri/here");

verify(requestProcessor).buildAuthorizeUrl(eq(request), eq(response), eq("https://redirect.uri/here"), anyString(), anyString());
}
Expand All @@ -412,7 +412,7 @@ public void shouldSetLaxCookiesAndNoLegacyCookieWhenCodeFlow() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(1));
assertThat(headers, everyItem(is("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=Lax")));
assertThat(headers, everyItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; HttpOnly; SameSite=Lax")));
}

@Test
Expand All @@ -431,10 +431,10 @@ public void shouldSetSameSiteNoneCookiesAndLegacyCookieWhenIdTokenResponse() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(4));
assertThat(headers, hasItem("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=state; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem("com.auth0.nonce=nonce; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.nonce=nonce; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; HttpOnly")));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -454,8 +454,8 @@ public void shouldSetSameSiteNoneCookiesAndNoLegacyCookieWhenIdTokenResponse() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("com.auth0.nonce=nonce; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand Down Expand Up @@ -512,7 +512,7 @@ public void shouldCheckSessionFallbackWhenHandleCalledWithRequest() throws Excep
MockHttpServletResponse response = new MockHttpServletResponse();

// build auth URL using request and response, which stores state and nonce in cookies and also session as a fallback
String authUrl = controller.buildAuthorizeUrl(request, response,"https://redirect.uri/here")
String authUrl = controller.buildAuthorizeUrl(request, response, "https://redirect.uri/here")
.withState("state")
.withNonce("nonce")
.build();
Expand Down Expand Up @@ -581,6 +581,6 @@ public void shouldConfigureCookiePath() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(1));
assertThat(headers, everyItem(is("com.auth0.state=state; HttpOnly; Max-Age=600; Path=/Path; SameSite=Lax")));
assertThat(headers, everyItem(matchesPattern("com\\.auth0\\.state=state; Path=/Path; Max-Age=600; Expires=.*?; HttpOnly; SameSite=Lax")));
}
}
23 changes: 12 additions & 11 deletions src/test/java/com/auth0/AuthorizeUrlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Collection;
import java.util.Map;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.*;
Expand Down Expand Up @@ -91,8 +92,8 @@ public void shouldSetNonceSameSiteAndLegacyCookieByDefault() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -105,7 +106,7 @@ public void shouldSetNonceSameSiteAndNotLegacyCookieWhenConfigured() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand All @@ -117,8 +118,8 @@ public void shouldSetStateSameSiteAndLegacyCookieByDefault() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -131,7 +132,7 @@ public void shouldSetStateSameSiteAndNotLegacyCookieWhenConfigured() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand All @@ -144,7 +145,7 @@ public void shouldSetSecureCookieWhenConfiguredTrue() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=Lax; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=Lax")));
}

@Test
Expand All @@ -157,8 +158,8 @@ public void shouldSetSecureCookieWhenConfiguredFalseAndSameSiteNone() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/auth0/RequestProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down
Loading