Skip to content

Commit 9b4de0a

Browse files
committed
pass HTTPX client config
1 parent e0f01c0 commit 9b4de0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

fastapi_azure_auth/openid_config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import logging
2+
import ssl
23
from datetime import datetime, timedelta
34
from typing import TYPE_CHECKING, Any, Dict, List, Optional
5+
from typing import TYPE_CHECKING, Any, Dict, List, NotRequired, Optional, TypedDict
46

57
import jwt
68
from fastapi import HTTPException, status
@@ -12,19 +14,27 @@
1214
log = logging.getLogger('fastapi_azure_auth')
1315

1416

17+
class HttpClientConfig(TypedDict):
18+
verify: NotRequired[ssl.SSLContext]
19+
20+
1521
class OpenIdConfig:
1622
def __init__(
1723
self,
1824
tenant_id: Optional[str] = None,
1925
multi_tenant: bool = False,
2026
app_id: Optional[str] = None,
2127
config_url: Optional[str] = None,
28+
http_client_config: Optional[HttpClientConfig] = None,
2229
) -> None:
2330
self.tenant_id: Optional[str] = tenant_id
2431
self._config_timestamp: Optional[datetime] = None
2532
self.multi_tenant: bool = multi_tenant
2633
self.app_id = app_id
2734
self.config_url = config_url
35+
self.http_client_config: HttpClientConfig = (
36+
http_client_config or HttpClientConfig()
37+
)
2838

2939
self.authorization_endpoint: str
3040
self.signing_keys: dict[str, 'AllowedPublicKeys']
@@ -72,7 +82,7 @@ async def _load_openid_config(self) -> None:
7282
if self.app_id:
7383
config_url += f'?appid={self.app_id}'
7484

75-
async with AsyncClient(timeout=10) as client:
85+
async with AsyncClient(timeout=10, **self.http_client_config) as client:
7686
log.info('Fetching OpenID Connect config from %s', config_url)
7787
openid_response = await client.get(config_url)
7888
openid_response.raise_for_status()

0 commit comments

Comments
 (0)