forked from auth0/auth0-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
64 lines (59 loc) · 2.95 KB
/
Copy pathconfig.py
File metadata and controls
64 lines (59 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Configuration classes and utilities for auth0-api-python.
"""
from typing import TYPE_CHECKING, Callable, Optional, Union
if TYPE_CHECKING:
from .cache import CacheAdapter
class ApiClientOptions:
"""
Configuration for the ApiClient.
Args:
domain: The Auth0 domain for single-domain mode and client flows,
e.g., "my-tenant.us.auth0.com". Optional if domains is provided.
domains: List of allowed domains or a resolver function for multi-domain mode.
Can be a static list of domain strings or a callable that returns
allowed domains dynamically. Optional if domain is provided.
audience: The expected 'aud' claim in the token.
custom_fetch: Optional callable that can replace the default HTTP fetch logic.
cache_adapter: Custom cache implementation. If not provided, uses default InMemoryCache.
cache_ttl_seconds: Time-to-live for cache entries in seconds (default: 600 = 10 minutes).
cache_max_entries: Maximum number of cache entries before LRU eviction (default: 100).
dpop_enabled: Whether DPoP is enabled (default: True for backward compatibility).
dpop_required: Whether DPoP is required (default: False, allows both Bearer and DPoP).
dpop_iat_leeway: Leeway in seconds for DPoP proof iat claim (default: 30).
dpop_iat_offset: Maximum age in seconds for DPoP proof iat claim (default: 300).
client_id: Required for get_access_token_for_connection and get_token_by_exchange_profile.
client_secret: Required for get_access_token_for_connection and get_token_by_exchange_profile.
timeout: HTTP timeout in seconds for token endpoint requests (default: 10.0).
"""
def __init__(
self,
domain: Optional[str] = None,
audience: str = "",
domains: Optional[Union[list[str], Callable[[dict], list[str]]]] = None,
custom_fetch: Optional[Callable[..., object]] = None,
cache_adapter: Optional["CacheAdapter"] = None,
cache_ttl_seconds: int = 600,
cache_max_entries: int = 100,
dpop_enabled: bool = True,
dpop_required: bool = False,
dpop_iat_leeway: int = 30,
dpop_iat_offset: int = 300,
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
timeout: float = 10.0,
):
self.domain = domain
self.domains = domains
self.audience = audience
self.custom_fetch = custom_fetch
self.cache_adapter = cache_adapter
self.cache_ttl_seconds = cache_ttl_seconds
self.cache_max_entries = cache_max_entries
self.dpop_enabled = dpop_enabled
self.dpop_required = dpop_required
self.dpop_iat_leeway = dpop_iat_leeway
self.dpop_iat_offset = dpop_iat_offset
self.client_id = client_id
self.client_secret = client_secret
self.timeout = timeout