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
When a `DomainResolver` bean is present, it takes priority over the static `domains` list. The resolver receives a `RequestContext` with the request URL, headers, and the unverified `iss` claim from the token.
328
+
329
+
### 3. Domain + Domains Coexistence (Auth for Agents)
330
+
331
+
For Auth for Agents scenarios, `domain` and `domains` can coexist. The `domain` is used for Auth for Agents flows (token exchange, authorization), while `domains` is used for token validation:
332
+
333
+
```yaml
334
+
auth0:
335
+
domain: "primary-tenant.auth0.com" # For Auth for Agents flows
336
+
audience: "https://api.example.com"
337
+
domains: # For token validation
338
+
- "primary-tenant.auth0.com"
339
+
- "tenant2.auth0.com"
340
+
- "tenant3.auth0.com"
341
+
```
342
+
343
+
When both are present, the SDK always uses `domains` for token verification.
344
+
345
+
## Caching
346
+
347
+
The SDK caches OIDC discovery metadata and JWKS providers in a unified cache. By default, it uses a thread-safe in-memory LRU cache.
348
+
349
+
### Cache Configuration
350
+
351
+
```yaml
352
+
auth0:
353
+
domain: "your-tenant.auth0.com"
354
+
audience: "https://api.example.com"
355
+
cache-max-entries: 100 # Max entries before LRU eviction (default: 100)
356
+
cache-ttl-seconds: 600 # TTL per entry in seconds (default: 600 = 10 minutes)
357
+
```
358
+
359
+
Both OIDC discovery and JWKS entries count against the `cache-max-entries` limit.
360
+
361
+
### Custom Cache Implementation
362
+
363
+
Replace the default in-memory cache with a distributed backend (Redis, Memcached, etc.) by implementing the `AuthCache` interface and registering it as a Spring bean:
364
+
365
+
```java
366
+
import com.auth0.AuthCache;
367
+
368
+
public class RedisAuthCache implements AuthCache<Object> {
369
+
370
+
private final RedisTemplate<String, Object> redisTemplate;
371
+
private final Duration ttl;
372
+
373
+
public RedisAuthCache(RedisTemplate<String, Object> redisTemplate, Duration ttl) {
Register it as a bean — the auto-configuration picks it up automatically:
409
+
410
+
```java
411
+
@Configuration
412
+
public class CacheConfig {
413
+
414
+
@Bean
415
+
public AuthCache<Object> authCache(RedisTemplate<String, Object> redisTemplate) {
416
+
return new RedisAuthCache(redisTemplate, Duration.ofMinutes(10));
417
+
}
418
+
}
419
+
```
420
+
421
+
When a custom `AuthCache` bean is present, the `cache-max-entries` and `cache-ttl-seconds` properties are ignored — your implementation controls its own eviction and TTL.
422
+
283
423
## Configuration Reference
284
424
285
425
### Complete Configuration Example
286
426
287
427
```yaml
288
428
auth0:
289
-
# Required: Your Auth0 domain
429
+
# Required (unless domains or domainsResolver is set): Your Auth0 domain
290
430
domain: "your-tenant.auth0.com"
291
431
292
432
# Required: API identifier/audience
293
433
audience: "https://api.example.com"
294
434
435
+
# Optional: Static list of allowed issuer domains (MCD)
@@ -312,9 +466,12 @@ You can also configure using environment variables:
312
466
```bash
313
467
AUTH0_DOMAIN=your-tenant.auth0.com
314
468
AUTH0_AUDIENCE=https://api.example.com
469
+
AUTH0_DOMAINS=login.acme.com,auth.partner.com
315
470
AUTH0_DPOPMODE=ALLOWED
316
471
AUTH0_DPOPIATOFFSETSECONDS=300
317
472
AUTH0_DPOPIATLEEWAYSSECONDS=30
473
+
AUTH0_CACHEMAXENTRIES=100
474
+
AUTH0_CACHETTLSECONDS=600
318
475
```
319
476
320
477
> **Note:** Spring Boot environment variable binding removes dashes and is case-insensitive. Do not use underscores to separate words within a property name (e.g., use `AUTH0_DPOPMODE`, not `AUTH0_DPOP_MODE`).
0 commit comments