Skip to content

Commit 3443a60

Browse files
committed
Updated the branch
2 parents 84c2121 + c2955a7 commit 3443a60

12 files changed

Lines changed: 13 additions & 210 deletions

File tree

auth0-api-java/src/main/java/com/auth0/AuthCache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
* OIDC discovery metadata and JWKS providers.
66
* <p>
77
* The SDK ships with a default in-memory LRU implementation
8-
* ({@link InMemoryAuthCache}). Developers can implement this interface
8+
* ({@link InMemoryAuthCache}). Users can implement this interface
99
* to plug in distributed cache backends (e.g., Redis, Memcached) without
1010
* breaking changes to the SDK's public API.
1111
* </p>
1212
*
13-
* <h3>Unified cache with key prefixes</h3>
1413
* <p>
1514
* A single {@code AuthCache<Object>} instance can serve as a unified cache
1615
* for both discovery metadata and JWKS providers by using key prefixes:

auth0-api-java/src/main/java/com/auth0/ClaimValidator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import java.util.*;
77

88
/**
9-
* Utility class for JWT claim validation
10-
*
11-
* Provides functionality to validate JWT claims including scopes and custom
12-
* claim checks.
9+
* Utility class for JWT claim validation. Provides functionality to validate JWT claims including scopes and custom claim checks.
1310
* This is the Java equivalent of the TypeScript claim validation utilities.
1411
*/
1512
class ClaimValidator {
@@ -27,13 +24,11 @@ static Set<String> getClaimValues(DecodedJWT jwt, String claimName) throws BaseA
2724
throw new VerifyAccessTokenException("Required claim is missing");
2825
}
2926

30-
// Case 1: space-separated string
3127
String strValue = jwt.getClaim(claimName).asString();
3228
if (strValue != null) {
3329
return new HashSet<>(Arrays.asList(strValue.trim().split("\\s+")));
3430
}
3531

36-
// Case 2: list of strings
3732
List<String> listValue = jwt.getClaim(claimName).asList(String.class);
3833
if (listValue != null) {
3934
return new HashSet<>(listValue);

auth0-api-java/src/main/java/com/auth0/InMemoryAuthCache.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public InMemoryAuthCache(int maxEntries, long ttlSeconds) {
6161
throw new IllegalArgumentException("ttlSeconds must not be negative");
6262
}
6363
this.ttlMillis = ttlSeconds * 1000;
64-
// accessOrder=true makes LinkedHashMap maintain LRU order
64+
6565
this.store = new LinkedHashMap<String, CacheEntry<V>>(maxEntries, 0.75f, true) {
6666
@Override
6767
protected boolean removeEldestEntry(Map.Entry<String, CacheEntry<V>> eldest) {
@@ -130,7 +130,7 @@ public int size() {
130130

131131
private boolean isExpired(CacheEntry<V> entry) {
132132
if (ttlMillis == 0) {
133-
return false; // TTL of 0 means no expiration
133+
return false;
134134
}
135135
return (System.currentTimeMillis() - entry.createdAt) > ttlMillis;
136136
}

auth0-api-java/src/main/java/com/auth0/JWTValidator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,9 @@ public DecodedJWT validateToken(String token, HttpRequestInfo httpRequestInfo) t
133133

134134
List<String> allowedDomains = resolveAllowedDomains(tokenIss, httpRequestInfo);
135135

136-
// Normalize the token issuer and allowed domains for consistent comparison
137136
String normalizedIss = normalizeToUrl(tokenIss);
138137
if (!allowedDomains.contains(normalizedIss)) {
139-
throw new VerifyAccessTokenException(
140-
String.format("Token issuer '%s' is not in the allowed list: %s"));
138+
throw new VerifyAccessTokenException("Token issuer is not in the allowed list");
141139
}
142140

143141
OidcMetadata discovery = performOidcDiscovery(tokenIss);

auth0-api-java/src/main/java/com/auth0/examples/Auth0ApiExample.java

Lines changed: 0 additions & 134 deletions
This file was deleted.

auth0-api-java/src/main/java/com/auth0/models/AuthOptions.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ public Builder cacheTtlSeconds(long ttlSeconds) {
229229
}
230230

231231
/**
232-
* Sets a custom cache implementation for both OIDC discovery metadata
233-
* and JWKS providers.
232+
* Sets a custom cache implementation for both OIDC discovery metadata and JWKS providers.
234233
* <p>
235234
* The cache uses a unified key-prefix scheme:
236235
* <ul>
@@ -251,13 +250,11 @@ public Builder cache(AuthCache<Object> cache) {
251250
}
252251

253252
public AuthOptions build() {
254-
// Mutual exclusivity: domains and domainsResolver cannot both be set
255253
if (domains != null && !domains.isEmpty() && domainsResolver != null) {
256254
throw new IllegalArgumentException(
257255
"Cannot configure both 'domains' and 'domainsResolver'. Use one or the other.");
258256
}
259257

260-
// At least one domain source must be provided
261258
boolean hasDomain = domain != null && !domain.isEmpty();
262259
boolean hasDomains = domains != null && !domains.isEmpty();
263260
boolean hasResolver = domainsResolver != null;

auth0-api-java/src/main/java/com/auth0/models/OidcMetadata.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
package com.auth0.models;
22

33
/**
4-
* Represents the relevant fields from an OIDC Discovery document
5-
* ({@code .well-known/openid-configuration}).
6-
* <p>
7-
* Only the fields required for JWT validation are extracted:
8-
* <ul>
9-
* <li>{@code issuer} — the canonical issuer identifier (used for
10-
* double-validation)</li>
11-
* <li>{@code jwks_uri} — the URL of the JSON Web Key Set (used to fetch signing
12-
* keys)</li>
13-
* </ul>
4+
* Represents the relevant fields from the OIDC discovery document.
145
*/
156
public class OidcMetadata {
167

auth0-api-java/src/main/java/com/auth0/models/RequestContext.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,7 @@
44
import java.util.Map;
55

66
/**
7-
* Provides request context to the {@link com.auth0.DomainResolver} for dynamic
8-
* issuer resolution.
9-
* <p>
10-
* This is the "silver platter" passed to the developer's resolver function,
11-
* containing all the
12-
* data needed to make a routing decision in multi-custom-domain scenarios.
13-
* </p>
14-
*
15-
* <ul>
16-
* <li>{@code url} — The URL the API request was made to</li>
17-
* <li>{@code headers} — Relevant request headers (e.g., Host,
18-
* X-Forwarded-Host)</li>
19-
* <li>{@code tokenIssuer} — The <b>unverified</b> {@code iss} claim extracted
20-
* from the incoming JWT</li>
21-
* </ul>
7+
* Contextual information about the incoming API request, provided to the domain resolver.
228
*/
239
public class RequestContext {
2410

@@ -54,12 +40,6 @@ public Map<String, String> getHeaders() {
5440

5541
/**
5642
* Returns the unverified {@code iss} claim from the incoming JWT.
57-
* <p>
58-
* <b>Warning:</b> This value has NOT been verified yet. It is provided so the
59-
* resolver
60-
* can use it as a hint for routing decisions, but it must not be trusted on its
61-
* own.
62-
* </p>
6343
*
6444
* @return the unverified token issuer, or {@code null} if not available
6545
*/

auth0-springboot-api-playground/src/main/java/com/auth0/playground/ProfileController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.auth0.playground;
22

3-
import org.springframework.http.ResponseEntity;
43
import com.auth0.spring.boot.Auth0AuthenticationToken;
4+
import org.springframework.http.ResponseEntity;
55
import org.springframework.security.core.Authentication;
66
import org.springframework.web.bind.annotation.GetMapping;
77
import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,7 +16,7 @@ public class ProfileController {
1616

1717
@GetMapping("/protected")
1818
public ResponseEntity<Map<String, Object>> protectedEndpoint(Authentication authentication) {
19-
String userId = authentication.getName(); // Returns the 'sub' claim
19+
String userId = authentication.getName();
2020

2121
return ResponseEntity.ok(Map.of(
2222
"message", "Access granted!",

auth0-springboot-api/src/main/java/com/auth0/spring/boot/Auth0AutoConfiguration.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,7 @@
1010
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1111
import org.springframework.context.annotation.Bean;
1212

13-
/**
14-
* Autoconfiguration for Auth0 authentication and JWT validation.
15-
*
16-
* <p>Supports three domain configuration modes (mutually exclusive):
17-
*
18-
* <ol>
19-
* <li><b>Single domain</b> — set {@code auth0.domain} in YAML
20-
* <li><b>Static MCD list</b> — set {@code auth0.domains} in YAML
21-
* <li><b>Dynamic resolver</b> — define a {@link DomainResolver} bean
22-
* </ol>
23-
*
24-
* Dynamic Domain Resolver
25-
*
26-
* <p>To dynamically resolve allowed issuer domains at request time, define a bean implementing
27-
* {@link DomainResolver}:
28-
*
29-
* <pre>{@code
30-
* @Bean
31-
* public DomainResolver domainResolver() {
32-
* return context -> {
33-
* String tenantId = context.getHeaders().get("x-tenant-id");
34-
* return lookupDomainsForTenant(tenantId);
35-
* };
36-
* }
37-
* }</pre>
38-
*/
13+
/** Autoconfiguration for Auth0 authentication and JWT validation. */
3914
@AutoConfiguration
4015
@EnableConfigurationProperties(Auth0Properties.class)
4116
public class Auth0AutoConfiguration {

0 commit comments

Comments
 (0)