Skip to content

Commit 5d2d911

Browse files
authored
Merge v2-dev branch to master (#516)
2 parents d82d783 + 49833df commit 5d2d911

207 files changed

Lines changed: 7077 additions & 4333 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ workflows:
6262
jobs:
6363
- build
6464

65-
api-diff:
66-
jobs:
67-
- api-diff
65+
# api-diff:
66+
# jobs:
67+
# - api-diff

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# Change Log
22

3+
## [2.0.0 Beta 2](https://github.com/auth0/auth0-java/tree/2.0.0-beta.2) (2023-02-13)
4+
[Full Changelog](https://github.com/auth0/auth0-java/compare/2.0.0-beta.1...2.0.0-beta.2)
5+
6+
**Changed**
7+
- Update to latest java-jwt version [\#512](https://github.com/auth0/auth0-java/pull/512) ([jimmyjames](https://github.com/jimmyjames))
8+
9+
## [2.0.0 Beta 1](https://github.com/auth0/auth0-java/tree/2.0.0-beta.1) (2023-01-26)
10+
[Full Changelog](https://github.com/auth0/auth0-java/compare/2.0.0-beta.0...2.0.0-beta.1)
11+
12+
**Added**
13+
- Add support for MFA APIs [\#505](https://github.com/auth0/auth0-java/pull/505) ([poovamraj](https://github.com/poovamraj))
14+
- Add support MFA Methods API [\#506](https://github.com/auth0/auth0-java/pull/506) ([poovamraj](https://github.com/poovamraj))
15+
- Support JWT Client Authentication [\#507](https://github.com/auth0/auth0-java/pull/507) ([jimmyjames](https://github.com/jimmyjames))
16+
17+
## [2.0.0 Beta 0](https://github.com/auth0/auth0-java/tree/2.0.0-beta.0) (2023-01-12)
18+
[Full Changelog](https://github.com/auth0/auth0-java/compare/1.44.2...2.0.0-beta.0)
19+
20+
> **Warning** This SDK is in beta and is subject to breaking changes. It is not recommended for production use, but your feedback and help in testing is appreciated!
21+
22+
This release introduces several enhancement, including:
23+
- HTTP response information returned from requests
24+
- Additional HTTP client configurability
25+
- Authentication API improvements to not require a client secret
26+
- ... and more!
27+
28+
Please see the [Migration Guide](MIGRATION_GUIDE.md) for guidance on updating your application.
29+
330
## [1.44.2](https://github.com/auth0/auth0-java/tree/1.44.2) (2023-01-11)
431
[Full Changelog](https://github.com/auth0/auth0-java/compare/1.44.1...1.44.2)
532

EXAMPLES.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ An `APIException` will be thrown if the network request succeeded, but another e
1515
```java
1616
Request<UsersPage> request = api.users().list(new UserFilter().withSearchEngine("v1"));
1717
try {
18-
UsersPage usersPage = request.execute();
18+
UsersPage usersPage = request.execute().getBody();
1919
} catch(APIException apiException) {
2020
apiException.getStatusCode(); // 400
2121
apiException.getError(); // "operation_not_supported"
@@ -25,24 +25,28 @@ try {
2525

2626
## HTTP Client configuration
2727

28-
Both the Authentication and Management API clients use the OkHttp networking library. Certain configurations of the client are available via the `HttpOptions` object, which can passed to both API client constructors.
28+
By default, both the Authentication and Management API clients use the OkHttp networking library to make HTTP requests.
29+
The client can be configured by building a `DefaultHttpClient` and providing it to the API clients.
30+
If using both the Management and Authentication API clients, it is recommended to create one `Auth0HttpClient` to be used by both API clients to minimize resource usage.
2931

3032
```java
31-
HttpOptions options = new HttpOptions();
33+
Auth0HttpClient client = DefaultHttpClient.newBuilder()
34+
// configure as needed
35+
.build();
3236

33-
// configure timeouts; default is ten seconds for both connect and read timeouts:
34-
options.setConnectTimeout(5);
35-
options.setReadTimeout(15);
37+
AuthAPI auth = AuthAPI.newBuilder("DOMAIN", "CLIENT-ID", "CLIENT-SECRET")
38+
.withHttpClient(client)
39+
.build();
3640

37-
// configure proxy:
38-
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("{IP-ADDRESS}", {PORT}));
39-
ProxyOptions proxyOptions = new ProxyOptions(proxy);
40-
options.setProxyOptions(proxyOptions);
41-
42-
// create client
43-
AuthAPI authAPI = new AuthAPI("{CLIENT_ID}", "{CLIENT_SECRET}", options);
41+
ManagementAPI mgmt = ManagementAPI.newBuilder("DOMAIN", "API-TOKEN")
42+
.withHttpClient(client)
43+
.build();
4444
```
4545

46+
If the `DefaultHttpClient` does not support your required networking client configuration, you may choose to implement
47+
your own client by implementing the `Auth0HttpClient` interface and providing it to the API clients. This is an advanced
48+
use case and should be used only when necessary.
49+
4650
## Verifying an ID token
4751

4852
This library also provides the ability to validate an OIDC-compliant ID Token, according to the [OIDC Specification](https://openid.net/specs/openid-connect-core-1_0-final.html#IDTokenValidation).
@@ -100,7 +104,7 @@ Note that Organizations is currently only available to customers on our Enterpri
100104
Log in to an organization by using `withOrganization()` when building the Authorization URL:
101105

102106
```java
103-
AuthAPI auth = new AuthAPI("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}");
107+
AuthAPI auth = AuthAPI.newBuilder("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}").build();
104108
String url = auth.authorizeUrl("https://me.auth0.com/callback")
105109
.withOrganization("{YOUR_ORGANIZATION_ID")
106110
.build();
@@ -120,7 +124,7 @@ IdTokenVerifier.init("{ISSUER}", "{AUDIENCE}", signatureVerifier)
120124
Accept a user invitation by using `withInvitation()` when building the Authorization URL:
121125

122126
```
123-
AuthAPI auth = new AuthAPI("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}");
127+
AuthAPI auth = AuthAPI.newBuilder("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}").build();
124128
String url = auth.authorizeUrl("https://me.auth0.com/callback")
125129
.withOrganization("{YOUR_ORGANIZATION_ID")
126130
.withInvitation("{YOUR_INVITATION_ID}")
@@ -132,6 +136,6 @@ String url = auth.authorizeUrl("https://me.auth0.com/callback")
132136
Requests can be executed asynchronously, using the `executeAsync()` method, which returns a `CompletableFuture<T>`.
133137

134138
```java
135-
CompletableFuture<User> userFuture = mgmt.users().getUser("auth0|123", new UserFilter()).executeAsync();
136-
User user = userFuture.get();
139+
CompletableFuture<Response<User>> userFuture = mgmt.users().getUser("auth0|123", new UserFilter()).executeAsync();
140+
User user = userFuture.get().getBody();
137141
```

MIGRATION_GUIDE.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Migration Guide
2+
3+
## Migrating from v1 to v2
4+
5+
The version 2 release includes several notable improvements, including:
6+
7+
* Requests can now be configured with additional parameters and headers, without needing to downcast to `CustomRequest`.
8+
* Responses are now wrapped in a new `com.auth0.net.Response` type, which provides information about the HTTP response such as headers and status code.
9+
* The `AuthAPI` and `ManagementAPI` clients can now share the same HTTP client.
10+
* The `AuthAPI` client no longer requires a client secret, enabling support for APIs and scenarios where a secret is not required.
11+
12+
Version 2 includes breaking changes. Please read this guide to learn how to update your application for v2.
13+
14+
### Configuring `auth0-java` v2
15+
16+
To create the API clients, use the new builders, and specify any HTTP-related configurations with the new `DefaultHttpClient`:
17+
18+
```java
19+
Auth0HttpClient http = DefaultHttpClient.newBuilder()
20+
.withConnectTimeout(10)
21+
.withReadTimeout(10)
22+
// additional configurations as needed
23+
.build();
24+
25+
AuthAPI auth = AuthAPI.newBuilder("{DOMAIN}", "{CLIENT-ID}", "{OPTIONAL-CLIENT-SECRET}")
26+
.withHttpClient(http)
27+
.build();
28+
29+
ManagementAPI mgmt = ManagementAPI.newBuilder("{DOMAIN}", "{API-TOKEN}")
30+
.withHttpClient(http)
31+
.build();
32+
```
33+
34+
### Response information
35+
36+
Version 2 returns HTTP response information such as status code and headers in a new `com.auth0.net.Response` type.
37+
Instead of simply returning the parsed JSON response body from requests, all API methods now return a `Response<T>`.
38+
If you have no need for the response information, replace any calls to `execute()` with `execute().getBody()` to get the returned response body as before:
39+
40+
```java
41+
// Get response info
42+
Response<User> userResponse = api.users().get("{USER-ID}", null);
43+
int code = userResponse.getStatusCode();
44+
Map<String, String> headers = userResponse.getHeaders();
45+
46+
// Just get the response body
47+
User user = api.users().get("{USER-ID}", null).execute().getBody();
48+
```
49+
50+
### Request configuration
51+
52+
Previously, only requests that returned a `CustomizableRequest` (or its implementation, `CustomRequest`) allowed for a request to be configured with additional parameters or headers.
53+
In v2, the `com.auth0.net.Request` interface defines the new methods:
54+
55+
- `Request<T> addHeader(String name, String value)`
56+
- `Request<T> addParameter(String name, Object value)`
57+
- `Request<T> setBody(Object body)`
58+
59+
This enables all requests to be configured, without the need to downcast to `CustomizableRequest` or `CustomRequest`.
60+
If you were down-casting to these types, you will need to remove the cast and instead configure the request directly:
61+
62+
```java
63+
Request<User> userRequest = api.users().get("{USER-ID}", null);
64+
userRequest.addHeader("some-header", "some-value");
65+
Response<User> userResponse = userRequest.execute();
66+
```
67+
68+
### Detailed changes
69+
70+
The following summarizes details of the changes in version 2, including types and methods removed, added, or deprecated.
71+
72+
#### Removed classes
73+
74+
- `AuthRequest` has been removed. Use `TokenRequest` instead.
75+
- `CustomizableRequest` and `CustomRequest` have been removed. The `Request` interface now supports request customization directly without the need to downcast.
76+
- `FormDataRequest` has been removed. Use `MultipartRequest` instead.
77+
- `CreateUserRequest` has been removed. Use `SignUpRequest` instead.
78+
79+
#### Moved classes
80+
81+
- `com.auth0.json.mgmt.Token` moved to `com.auth0.json.mgmt.blacklists.Token`
82+
- `com.auth0.json.mgmt.ClientGrant` moved to `com.auth0.json.mgmt.clientgrants.ClientGrant`
83+
- `com.auth0.json.mgmt.ClientGrantsPage` moved to `com.auth0.json.mgmt.clientgrants.ClientGrantsPage`
84+
- `com.auth0.json.mgmt.Connection` moved to `com.auth0.json.mgmt.connections.Connection`
85+
- `com.auth0.json.mgmt.ConnectionsPage` moved to `com.auth0.json.mgmt.connections.ConnectionsPage`
86+
- `com.auth0.json.mgmt.DeviceCredentials` moved to `com.auth0.json.mgmt.devicecredentials.DeviceCredentials`
87+
- `com.auth0.json.mgmt.EmailTemplate` moved to `com.auth0.json.mgmt.emailtemplates.EmailTemplate`
88+
- `com.auth0.json.mgmt.Grant` moved to `com.auth0.json.mgmt.grants.Grant`
89+
- `com.auth0.json.mgmt.GrantsPage` moved to `com.auth0.json.mgmt.grants.GrantsPage`
90+
- `com.auth0.json.mgmt.EmailVerificationIdentity` moved to `com.auth0.json.mgmt.tickets.EmailVerificationIdentity`
91+
- `com.auth0.json.mgmt.Key;` moved to `com.auth0.json.mgmt.keys.Key`
92+
- `com.auth0.json.mgmt.RolesPage` moved to `com.auth0.json.mgmt.roles.RolesPage`
93+
- `com.auth0.json.mgmt.ResourceServer` moved to `com.auth0.json.mgmt.resourceserver.ResourceServer`
94+
- `com.auth0.json.mgmt.ResourceServersPage` moved to `com.auth0.json.mgmt.resourceserver.ResourceServersPage`
95+
- `com.auth0.json.mgmt.Permission` moved to `com.auth0.json.mgmt.permissions.Permission`
96+
- `com.auth0.json.mgmt.PermissionsPage` moved to `com.auth0.json.mgmt.permissions.PermissionsPage`
97+
- `com.auth0.json.mgmt.Role` moved to `com.auth0.json.mgmt.roles.Role`
98+
- `com.auth0.json.mgmt.RolesPage` moved to `com.auth0.json.mgmt.roles.RolesPage`
99+
- `com.auth0.json.mgmt.RulesConfig` moved to `com.auth0.json.mgmt.rules.RulesConfig`
100+
- `com.auth0.json.mgmt.Rule` moved to `com.auth0.json.mgmt.rules.Rule`
101+
- `com.auth0.json.mgmt.RulesPage` moved to `com.auth0.json.mgmt.rules.RulesPage`
102+
- `com.auth0.json.mgmt.DailyStats` moved to `com.auth0.json.mgmt.stats.DailyStats`
103+
- `com.auth0.json.mgmt.Permission` moved to `com.auth0.json.mgmt.permissions.Permission`
104+
- `com.auth0.json.mgmt.PermissionsPage` moved to `com.auth0.json.mgmt.permissions.PermissionsPage`
105+
- `com.auth0.json.mgmt.RolesPage` moved to `com.auth0.json.mgmt.roles.RolesPage`
106+
107+
#### Removed methods
108+
109+
- `void com.auth0.client.mgmt.ManagementAPI#doNotSendTelemetry()` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
110+
- `void com.auth0.client.auth.AuthAPI#doNotSendTelemetry()` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
111+
- `void com.auth0.client.mgmt.ManagementAPI#setTelemetry(Telemetry telemetry)` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
112+
- `void com.auth0.client.auth.AuthAP#setTelemetry(Telemetry telemetry)` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
113+
- Deprecated `void com.auth0.client.mgmt.ManagementAPI#setLoggingEnabled(boolean enabled)` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
114+
- Deprecated `void com.auth0.client.auth.AuthAPI#setLoggingEnabled(boolean enabled)` has been removed. Telemetry configuration can be done using the `DefaultHttpClient#Builder`
115+
- Deprecated `Request<List<ClientGrant>> com.auth0.client.mgmt.ClientGrantsEntity#list()` has been removed. Use `Request<ClientGrantsPage> list(ClientGrantsFilter filter) com.auth0.client.mgmt.ClientGrantsEntity#list(ClientGrantsFilter filter)` instead.
116+
- Deprecated `Request<List<Client>> com.auth0.client.mgmt.ClientsEntity#list()` has been removed. Use `Request<ClientsPage> com.auth0.client.mgmt.ClientsEntity#list(ClientFilter filter)` instead.
117+
- Deprecated `Request<List<Connection>> com.auth0.client.mgmt.ClientsEntity#list(ConnectionFilter filter)` has been removed. Use `Request<ConnectionsPage> com.auth0.client.mgmt.ClientsEntity#listAll(ConnectionFilter filter)` instead.
118+
- Deprecated `Request<List<Grant>> com.auth0.client.mgmt.GrantsEntity#list(String userId)` has been removed. Use `Request<GrantsPage> com.auth0.client.mgmt.GrantsEntity#list(String userId, GrantsFilter filter)` instead.
119+
- Deprecated `Request<List<ResourceServer>> com.auth0.client.mgmt.ResourceServerEntity#list()` has been removed. Use `Request<ResourceServersPage> com.auth0.client.mgmt.ResourceServersEntity#list(ResourceServersFilter)` instead.
120+
- Deprecated `Request<List<Rule>> com.auth0.client.mgmt.RulesEntity#list(RulesFilter filter)` has been removed. Use `Request<RulesPage> com.auth0.client.mgmt.RulesEntity#listAll(RulesFilter filter)` instead.
121+
- Deprecated `void com.auth0.json.mgmt.guardian.EnrollmentTicket#setUserId(String id)` has been removed. Use the constructor instead.
122+
- Deprecated `com.auth0.json.mgmt.guardian.SNSFactorProvider` no-arg constructor has been removed. Use the full constructor instead.
123+
- Deprecated `void com.auth0.json.mgmt.guardian.SNSFactorProvider#setAWSAccessKeyId(String awsAccessKeyId)` has been removed. Use the constructor instead.
124+
- Deprecated `void com.auth0.json.mgmt.guardian.SNSFactorProvider#setAWSSecretAccessKey(String awsSecretAccessKey)` has been removed. Use the constructor instead.
125+
- Deprecated `void com.auth0.json.mgmt.guardian.SNSFactorProvider#setAWSRegion(String awsRegion)` has been removed. Use the constructor instead.
126+
- Deprecated `void com.auth0.json.mgmt.guardian.SNSFactorProvider#setSNSAPNSPlatformApplicationARN(String apnARN)` has been removed. Use the constructor instead.
127+
- Deprecated `void com.auth0.json.mgmt.guardian.SNSFactorProvider#setSNSGCMPlatformApplicationARN(String gcmARN)` has been removed. Use the constructor instead.
128+
- Deprecated `com.auth0.json.mgmt.guardian.TwilioFactorProvider` no-arg constructor has been removed. Use the full constructor instead.
129+
- Deprecated `void com.auth0.json.mgmt.guardian.TwilioFactorProvider#setFrom(String from)` has been removed. Use the constructor instead.
130+
- Deprecated `void com.auth0.json.mgmt.guardian.TwilioFactorProvider#setMessagingServiceSID(String messagingServiceSID)` has been removed. Use the constructor instead.
131+
- Deprecated `void com.auth0.json.mgmt.guardian.TwilioFactorProvider#setAuthToken(String authToken)` has been removed. Use the constructor instead.
132+
- Deprecated `void com.auth0.json.mgmt.guardian.TwilioFactorProvider#setSID(String SID)` has been removed. Use the constructor instead.
133+
- The default implementation of `com.auth0.net.Request#executeAsync()` has been removed; implementations must provide an implementation of `executeAsync`.
134+
135+
### New classes and methods
136+
137+
#### Refactored HTTP layer types
138+
139+
Version 2 introduces a new abstraction, `com.auth0.net.client.Auth0HttpClient`, to handle the core HTTP responsibilities of sending HTTP requests.
140+
An implementation is provided in `DefaultHttpClient`, which supports all the configurations available in the now-deprecated `HttpOptions`.
141+
In addition to these configurations, it is also possible to implement the `Auth0HttpClient` for advanced use-cases where the default implementation or its configurations are not sufficient.
142+
Several new types have been added to support this:
143+
144+
- `com.auth0.net.client.Auth0HttpClient` has been added to define the HTTP client interface.
145+
- `com.auth0.net.client.DefaultHttpClient` is the default HTTP implementation that should be used in the majority of cases. It supports the same configurations as `HttpOptions`, but can be reused across API clients. It uses `OkHttp` as the networking client internally.
146+
- `com.auth0.net.client.Auth0HttpRequest` is a lightweight representation of an HTTP request to execute. Internal API implementations will form the request.
147+
- `com.auth0.net.client.Auth0HttpResponse` is a lightweight representation of an HTTP response. Internal API implementations will parse the response.
148+
- `com.auth0.net.client.HttpMethod` is an `enum` representing the HTTP methods.
149+
150+
### New deprecations
151+
152+
- `com.auth0.client.HttpOptions` has been deprecated, in favor of configuring the `DefaultHttpClient` directly.
153+
- `com.auth0.client.mgmt.ManagementAPI` constructors have been deprecated in favor of `ManagementAPI#newBuilder(String domain, String apiToken)`.
154+
- `com.auth0.client.auth.AuthAPI` constructors have been deprecated in favor of `AuthAPI.newBuilder(String domain, String clientId)` and `AuthAPI.newBuilder(String domain, String clientId, String clientSecret)`.

0 commit comments

Comments
 (0)