Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uppgrad auth0-java version #152

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
java-version: 8
- uses: gradle/gradle-build-action@a4cf152f482c7ca97ef56ead29bf08bcd953284c
with:
arguments: assemble apiDiff check jacocoTestReport --continue --console=plain
# arguments: assemble apiDiff check jacocoTestReport --continue --console=plain
arguments: assemble check jacocoTestReport --continue --console=plain
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d
with:
flags: unittests
Expand Down
62 changes: 31 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ project.afterEvaluate {
}
}

project.configure(project) {
def baselineVersion = project.ext.baselineCompareVersion
task('apiDiff', type: JapicmpTask, dependsOn: 'jar') {
oldClasspath.from(files(getBaselineJar(project, baselineVersion)))
newClasspath.from(files(jar.archiveFile))
onlyModified = true
failOnModification = true
ignoreMissingClasses = true
htmlOutputFile = file("$buildDir/reports/apiDiff/apiDiff.html")
txtOutputFile = file("$buildDir/reports/apiDiff/apiDiff.txt")
doLast {
project.logger.quiet("Comparing against baseline version ${baselineVersion}")
}
}
}
// project.configure(project) {
// def baselineVersion = project.ext.baselineCompareVersion
// task('apiDiff', type: JapicmpTask, dependsOn: 'jar') {
// oldClasspath.from(files(getBaselineJar(project, baselineVersion)))
// newClasspath.from(files(jar.archiveFile))
// onlyModified = true
// failOnModification = true
// ignoreMissingClasses = true
// htmlOutputFile = file("$buildDir/reports/apiDiff/apiDiff.html")
// txtOutputFile = file("$buildDir/reports/apiDiff/apiDiff.txt")
// doLast {
// project.logger.quiet("Comparing against baseline version ${baselineVersion}")
// }
// }
// }
}

private static File getBaselineJar(Project project, String baselineVersion) {
// Use detached configuration: https://github.com/square/okhttp/blob/master/build.gradle#L270
def group = project.group
try {
def baseline = "${project.group}:${project.name}:$baselineVersion"
project.group = 'virtual_group_for_japicmp'
def dependency = project.dependencies.create(baseline + "@jar")
return project.configurations.detachedConfiguration(dependency).files.find {
it.name == "${project.name}-${baselineVersion}.jar"
}
} finally {
project.group = group
}
}
//private static File getBaselineJar(Project project, String baselineVersion) {
// // Use detached configuration: https://github.com/square/okhttp/blob/master/build.gradle#L270
// def group = project.group
// try {
// def baseline = "${project.group}:${project.name}:$baselineVersion"
// project.group = 'virtual_group_for_japicmp'
// def dependency = project.dependencies.create(baseline + "@jar")
// return project.configurations.detachedConfiguration(dependency).files.find {
// it.name == "${project.name}-${baselineVersion}.jar"
// }
// } finally {
// project.group = group
// }
//}

ext {
baselineCompareVersion = '1.5.0'
//baselineCompareVersion = '1.5.0'
testInJavaVersions = [8, 11, 17, 21]
}

Expand Down Expand Up @@ -125,7 +125,7 @@ dependencies {
implementation 'com.google.guava:guava-annotations:r03'
implementation 'commons-codec:commons-codec:1.15'

api 'com.auth0:auth0:1.45.1'
api 'com.auth0:auth0:2.16.0'
api 'com.auth0:java-jwt:3.19.4'
api 'com.auth0:jwks-rsa:0.22.1'

Expand Down
55 changes: 11 additions & 44 deletions src/main/java/com/auth0/AuthenticationController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.auth0;

import com.auth0.client.HttpOptions;
import com.auth0.client.auth.AuthAPI;
import com.auth0.jwk.JwkProvider;
import com.auth0.net.Telemetry;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.DefaultHttpClient;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;

Expand Down Expand Up @@ -61,7 +61,6 @@ public static class Builder {
private boolean useLegacySameSiteCookie;
private String organization;
private String invitation;
private HttpOptions httpOptions;
private String cookiePath;

Builder(String domain, String clientId, String clientSecret) {
Expand All @@ -76,18 +75,6 @@ public static class Builder {
this.useLegacySameSiteCookie = true;
}

/**
* Customize certain aspects of the underlying HTTP client networking library, such as timeouts and proxy configuration.
*
* @param httpOptions a non-null {@code HttpOptions}
* @return this same builder instance.
*/
public Builder withHttpOptions(HttpOptions httpOptions) {
Validate.notNull(httpOptions);
this.httpOptions = httpOptions;
return this;
}

/**
* Specify that transient authentication-based cookies such as state and nonce are created with the specified
* {@code Path} cookie attribute.
Expand Down Expand Up @@ -196,8 +183,7 @@ public Builder withInvitation(String invitation) {
* @throws UnsupportedOperationException if the Implicit Grant is chosen and the environment doesn't support UTF-8 encoding.
*/
public AuthenticationController build() throws UnsupportedOperationException {
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret, httpOptions);
setupTelemetry(apiClient);
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret);

final boolean expectedAlgorithmIsExplicitlySetAndAsymmetric = jwkProvider != null;
final SignatureVerifier signatureVerifier;
Expand Down Expand Up @@ -234,17 +220,15 @@ IdTokenVerifier.Options createIdTokenVerificationOptions(String issuer, String a
}

@VisibleForTesting
AuthAPI createAPIClient(String domain, String clientId, String clientSecret, HttpOptions httpOptions) {
if (httpOptions != null) {
return new AuthAPI(domain, clientId, clientSecret, httpOptions);
}
return new AuthAPI(domain, clientId, clientSecret);
}
AuthAPI createAPIClient(String domain, String clientId, String clientSecret) {
Auth0HttpClient http = DefaultHttpClient.newBuilder()
.telemetryEnabled(true)
.build();

@VisibleForTesting
void setupTelemetry(AuthAPI client) {
Telemetry telemetry = new Telemetry("auth0-java-mvc-common", obtainPackageVersion());
client.setTelemetry(telemetry);

return AuthAPI.newBuilder(domain, clientId, clientSecret)
.withHttpClient(http)
.build();
}

@VisibleForTesting
Expand All @@ -265,23 +249,6 @@ private String getIssuer(String domain) {
}
}

/**
* Whether to enable or not the HTTP Logger for every Request and Response.
* Enabling this can expose sensitive information.
*
* @param enabled whether to enable the HTTP logger or not.
*/
public void setLoggingEnabled(boolean enabled) {
requestProcessor.getClient().setLoggingEnabled(enabled);
}

/**
* Disable sending the Telemetry header on every request to the Auth0 API
*/
public void doNotSendTelemetry() {
requestProcessor.getClient().doNotSendTelemetry();
}

/**
* Process a request to obtain a set of {@link Tokens} that represent successful authentication or authorization.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/auth0/AuthorizeUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public String fromPushedAuthorizationRequest() throws InvalidRequestException {
storeTransient();

try {
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute();
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute().getBody();
String requestUri = pushedAuthResponse.getRequestURI();
if (requestUri == null || requestUri.isEmpty()) {
throw new InvalidRequestException(API_ERROR, "The PAR request returned a missing or empty request_uri value");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/auth0/RequestProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ private void checkSessionState(HttpServletRequest request, String stateFromReque
private Tokens exchangeCodeForTokens(String authorizationCode, String redirectUri) throws Auth0Exception {
TokenHolder holder = client
.exchangeCode(authorizationCode, redirectUri)
.execute();
.execute()
.getBody();
return new Tokens(holder.getAccessToken(), holder.getIdToken(), holder.getRefreshToken(), holder.getTokenType(), holder.getExpiresIn());
}

Expand Down
Loading
Loading