You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comprehensive Java library for Auth0 JWT authentication with built-in **DPoP (Demonstration of Proof-of-Possession)** support. This multi-module project provides both a core authentication library and Spring Boot integration for secure API development.
9
+
A comprehensive Java library for Auth0 JWT authentication with built-in **DPoP (Demonstration of Proof-of-Possession)**and **Multi-Custom Domain (MCD)**support. This project provides both a core authentication library and Spring Boot integration for secure API development.
10
10
11
11
## 🏗️ Architecture Overview
12
12
@@ -49,6 +49,8 @@ The core library (`auth0-api-java`) is currently an internal module used by the
49
49
50
50
- JWT validation with Auth0 JWKS integration
51
51
- DPoP proof validation per [RFC 9449](https://datatracker.ietf.org/doc/html/rfc9449)
52
+
- Multi-Custom Domain (MCD) support — static domain lists, or dynamic resolution at request time
For tenants with multiple custom domains, the SDK can validate tokens from any of the configured issuers. There are three ways to configure domain resolution:
182
+
183
+
### Option 1: Static Domain List
184
+
185
+
Configure a list of allowed issuer domains in `application.yml`:
186
+
187
+
```yaml
188
+
auth0:
189
+
audience: "https://your-api-identifier"
190
+
domains:
191
+
- "login.acme.com"
192
+
- "auth.partner.com"
193
+
- "dev.example.com"
194
+
```
195
+
196
+
You can also set a primary domain alongside the list:
197
+
198
+
```yaml
199
+
auth0:
200
+
domain: "primary.auth0.com"
201
+
audience: "https://your-api-identifier"
202
+
domains:
203
+
- "login.acme.com"
204
+
- "auth.partner.com"
205
+
```
206
+
207
+
### Option 2: Dynamic Domain Resolver
208
+
209
+
For scenarios where the allowed issuers depend on runtime context (e.g., tenant headers, database lookups), define a `DomainResolver` bean:
210
+
211
+
```java
212
+
import com.auth0.DomainResolver;
213
+
214
+
@Configuration
215
+
public class McdConfig {
216
+
217
+
@Bean
218
+
public DomainResolver domainResolver(TenantService tenantService) {
When a `DomainResolver` bean is present, it takes precedence over the static `auth0.domains` list. The single `auth0.domain` can still coexist as a fallback.
232
+
233
+
### Option 3: Single Domain (Default)
234
+
235
+
For single-tenant setups, just use the `auth0.domain` property:
236
+
237
+
```yaml
238
+
auth0:
239
+
domain: "your-tenant.auth0.com"
240
+
audience: "https://your-api-identifier"
241
+
```
242
+
243
+
## Extensibility
244
+
245
+
### Custom Cache Implementation
246
+
247
+
The SDK caches OIDC discovery metadata and JWKS providers using a unified cache with key prefixes (`discovery:{issuerUrl}` and `jwks:{jwksUri}`). By default, it uses a thread-safe in-memory LRU cache.
248
+
249
+
You can replace this with a distributed cache (Redis, Memcached, etc.) by implementing the `AuthCache` interface:
250
+
251
+
```java
252
+
import com.auth0.AuthCache;
253
+
254
+
public class RedisAuthCache implements AuthCache<Object> {
255
+
256
+
private final RedisTemplate<String, Object> redisTemplate;
257
+
private final Duration ttl;
258
+
259
+
public RedisAuthCache(RedisTemplate<String, Object> redisTemplate, Duration ttl) {
Then define it as a Spring bean — the auto-configuration picks it up automatically and wires it into `AuthOptions`. No need to create your own `AuthClient` bean:
295
+
296
+
```java
297
+
@Configuration
298
+
public class CacheConfig {
299
+
300
+
@Bean
301
+
public AuthCache<Object> authCache(RedisTemplate<String, Object> redisTemplate) {
302
+
return new RedisAuthCache(redisTemplate, Duration.ofMinutes(10));
303
+
}
304
+
}
305
+
```
306
+
307
+
When an `AuthCache` bean is present, the `cacheMaxEntries` and `cacheTtlSeconds` YAML properties are ignored — your implementation controls its own eviction and TTL.
308
+
309
+
### Default Cache Settings
310
+
311
+
If no custom cache is provided, the built-in in-memory cache is used with these defaults:
312
+
313
+
```yaml
314
+
auth0:
315
+
cacheMaxEntries: 100 # max entries before LRU eviction
0 commit comments