1- import asyncio
21import inspect
32import logging
43from collections .abc import Callable
5- from typing import Any , Literal , Optional
4+ from typing import Any , Awaitable , Literal , Optional
65
76from fastapi .exceptions import HTTPException
87from fastapi .security import OAuth2AuthorizationCodeBearer , SecurityScopes
@@ -27,7 +26,7 @@ def __init__(
2726 scopes : Optional [dict [str , str ]] = None ,
2827 multi_tenant : bool = False ,
2928 validate_iss : bool = True ,
30- iss_callable : Optional [Callable [..., Any ]] = None ,
29+ iss_callable : Optional [Callable [[ str ], Awaitable [ str ] ]] = None ,
3130 token_version : Literal [1 , 2 ] = 2 ,
3231 openid_config_use_app_id : bool = False ,
3332 openapi_authorization_url : Optional [str ] = None ,
@@ -55,7 +54,7 @@ def __init__(
5554 :param validate_iss: bool
5655 **Only used for multi-tenant applications**
5756 Whether to validate the token `iss` (issuer) or not. This can be skipped to allow anyone to log in.
58- :param iss_callable: Callable
57+ :param iss_callable: Async Callable
5958 **Only used for multi-tenant application**
6059 Async function that has to accept a `tid` (tenant ID) and return a `iss` (issuer) or
6160 raise an InvalidIssuer exception
@@ -81,8 +80,6 @@ def __init__(
8180 if multi_tenant :
8281 if validate_iss and not callable (iss_callable ):
8382 raise RuntimeError ('`validate_iss` is enabled, so you must provide an `iss_callable`' )
84- elif iss_callable and not asyncio .iscoroutinefunction (iss_callable ):
85- raise RuntimeError ('`iss_callable` must be a coroutine' )
8683 elif iss_callable and 'tid' not in inspect .signature (iss_callable ).parameters .keys ():
8784 raise RuntimeError ('`iss_callable` must accept `tid` as an argument' )
8885
@@ -277,7 +274,7 @@ def __init__(
277274 auto_error : bool = True ,
278275 scopes : Optional [dict [str , str ]] = None ,
279276 validate_iss : bool = True ,
280- iss_callable : Optional [Callable [..., Any ]] = None ,
277+ iss_callable : Optional [Callable [[ str ], Awaitable [ str ] ]] = None ,
281278 openid_config_use_app_id : bool = False ,
282279 openapi_authorization_url : Optional [str ] = None ,
283280 openapi_token_url : Optional [str ] = None ,
@@ -299,7 +296,7 @@ def __init__(
299296
300297 :param validate_iss: bool
301298 Whether to validate the token `iss` (issuer) or not. This can be skipped to allow anyone to log in.
302- :param iss_callable: Callable
299+ :param iss_callable: Async Callable
303300 Async function that has to accept a `tid` (tenant ID) and return a `iss` (issuer) or
304301 raise an InvalidIssuer exception
305302 This is required when validate_iss is set to `True`.
0 commit comments