Skip to content

Commit e13f8d8

Browse files
committed
pass down http_client_config from AzureAuthorizationCodeBearerBase
1 parent 55db020 commit e13f8d8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

fastapi_azure_auth/auth.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
if TYPE_CHECKING: # pragma: no cover
3737
from jwt.algorithms import AllowedPublicKeys
3838

39-
log = logging.getLogger('fastapi_azure_auth')
39+
from fastapi_azure_auth.openid_config import HttpClientConfig
40+
41+
log = logging.getLogger("fastapi_azure_auth")
4042

4143

4244
class AzureAuthorizationCodeBearerBase(SecurityBase):
@@ -57,6 +59,7 @@ def __init__(
5759
openid_config_url: Optional[str] = None,
5860
openapi_description: Optional[str] = None,
5961
scheme_name: str = "AzureAuthorizationCodeBearerBase",
62+
http_client_config: Optional["HttpClientConfig"] = None,
6063
) -> None:
6164
"""
6265
Initialize settings.
@@ -107,6 +110,8 @@ def __init__(
107110
:param scheme_name: str
108111
The name of the security scheme to be used in OpenAPI documentation.
109112
Default is 'AzureAuthorizationCodeBearerBase'.
113+
:param http_client_config: HttpClientConfig
114+
Configuration for the HTTP client used to fetch the OpenID configuration.
110115
"""
111116
self.auto_error = auto_error
112117
# Validate settings, making sure there's no misconfigured dependencies out there
@@ -123,6 +128,7 @@ def __init__(
123128
multi_tenant=self.multi_tenant,
124129
app_id=app_client_id if openid_config_use_app_id else None,
125130
config_url=openid_config_url or None,
131+
http_client_config=http_client_config,
126132
)
127133

128134
self.leeway: int = leeway
@@ -302,6 +308,7 @@ def __init__(
302308
openapi_token_url: Optional[str] = None,
303309
openapi_description: Optional[str] = None,
304310
scheme_name: str = "AzureAD_PKCE_single_tenant",
311+
http_client_config: Optional["HttpClientConfig"] = None,
305312
) -> None:
306313
"""
307314
Initialize settings for a single tenant application.
@@ -340,6 +347,8 @@ def __init__(
340347
:param scheme_name: str
341348
The name of the security scheme to be used in OpenAPI documentation.
342349
Default is 'AzureAD_PKCE_single_tenant'.
350+
:param http_client_config: HttpClientConfig
351+
Configuration for the HTTP client used to fetch the OpenID configuration.
343352
"""
344353
super().__init__(
345354
app_client_id=app_client_id,
@@ -352,6 +361,7 @@ def __init__(
352361
openapi_authorization_url=openapi_authorization_url,
353362
openapi_token_url=openapi_token_url,
354363
openapi_description=openapi_description,
364+
http_client_config=http_client_config,
355365
)
356366
self.scheme_name: str = scheme_name
357367

@@ -371,6 +381,7 @@ def __init__(
371381
openapi_token_url: Optional[str] = None,
372382
openapi_description: Optional[str] = None,
373383
scheme_name: str = "AzureAD_PKCE_multi_tenant",
384+
http_client_config: Optional["HttpClientConfig"] = None,
374385
) -> None:
375386
"""
376387
Initialize settings for a multi-tenant application.
@@ -414,6 +425,8 @@ def __init__(
414425
:param scheme_name: str
415426
The name of the security scheme to be used in OpenAPI documentation.
416427
Default is 'AzureAD_PKCE_multi_tenant'.
428+
:param http_client_config: HttpClientConfig
429+
Configuration for the HTTP client used to fetch the OpenID configuration.
417430
"""
418431
super().__init__(
419432
app_client_id=app_client_id,
@@ -428,6 +441,7 @@ def __init__(
428441
openapi_authorization_url=openapi_authorization_url,
429442
openapi_token_url=openapi_token_url,
430443
openapi_description=openapi_description,
444+
http_client_config=http_client_config,
431445
)
432446
self.scheme_name: str = scheme_name
433447

@@ -447,6 +461,7 @@ def __init__(
447461
openapi_token_url: Optional[str] = None,
448462
openapi_description: Optional[str] = None,
449463
scheme_name: str = "AzureAD_PKCE_B2C_multi_tenant",
464+
http_client_config: Optional["HttpClientConfig"] = None,
450465
) -> None:
451466
"""
452467
Initialize settings for a B2C multi-tenant application.
@@ -485,6 +500,8 @@ def __init__(
485500
:param scheme_name: str
486501
The name of the security scheme to be used in OpenAPI documentation.
487502
Default is 'AzureAD_PKCE_B2C_multi_tenant'.
503+
:param http_client_config: HttpClientConfig
504+
Configuration for the HTTP client used to fetch the OpenID configuration.
488505
"""
489506
super().__init__(
490507
app_client_id=app_client_id,
@@ -500,5 +517,6 @@ def __init__(
500517
openapi_authorization_url=openapi_authorization_url,
501518
openapi_token_url=openapi_token_url,
502519
openapi_description=openapi_description,
520+
http_client_config=http_client_config,
503521
)
504522
self.scheme_name: str = scheme_name

0 commit comments

Comments
 (0)