diff --git a/auth0/authentication/async_token_verifier.py b/auth0/authentication/async_token_verifier.py index b6d5fcee..058e493f 100644 --- a/auth0/authentication/async_token_verifier.py +++ b/auth0/authentication/async_token_verifier.py @@ -40,7 +40,7 @@ async def _fetch_key(self, key_id=None): key_id (str): The key's key id.""" return await self._fetcher.get_key(key_id) - async def verify_signature(self, token): + async def verify_signature(self, token) -> dict[str, Any]: """Verifies the signature of the given JSON web token. Args: diff --git a/auth0/authentication/client_authentication.py b/auth0/authentication/client_authentication.py index 2b6b345f..849058f4 100644 --- a/auth0/authentication/client_authentication.py +++ b/auth0/authentication/client_authentication.py @@ -10,7 +10,7 @@ def create_client_assertion_jwt( domain: str, client_id: str, - client_assertion_signing_key: str | None, + client_assertion_signing_key: str, client_assertion_signing_alg: str | None, ) -> str: """Creates a JWT for the client_assertion field. @@ -18,7 +18,7 @@ def create_client_assertion_jwt( Args: domain (str): The domain of your Auth0 tenant client_id (str): Your application's client ID - client_assertion_signing_key (str, optional): Private key used to sign the client assertion JWT + client_assertion_signing_key (str): Private key used to sign the client assertion JWT client_assertion_signing_alg (str, optional): Algorithm used to sign the client assertion JWT (defaults to 'RS256') Returns: diff --git a/auth0/authentication/token_verifier.py b/auth0/authentication/token_verifier.py index a08ae5d9..6f745e7c 100644 --- a/auth0/authentication/token_verifier.py +++ b/auth0/authentication/token_verifier.py @@ -39,7 +39,7 @@ def __init__(self, algorithm: str) -> None: raise ValueError("algorithm must be specified.") self._algorithm = algorithm - def _fetch_key(self, key_id: str | None = None) -> str | RSAPublicKey: + def _fetch_key(self, key_id: str) -> str | RSAPublicKey: """Obtains the key associated to the given key id. Must be implemented by subclasses. @@ -111,6 +111,8 @@ def verify_signature(self, token: str) -> dict[str, Any]: or the token's signature doesn't match the calculated one. """ kid = self._get_kid(token) + if kid is None: + kid = "" secret_or_certificate = self._fetch_key(key_id=kid) return self._decode_jwt(token, secret_or_certificate) # type: ignore[arg-type] @@ -128,7 +130,7 @@ def __init__(self, shared_secret: str, algorithm: str = "HS256") -> None: super().__init__(algorithm) self._shared_secret = shared_secret - def _fetch_key(self, key_id: str | None = None) -> str: + def _fetch_key(self, key_id: str = "") -> str: return self._shared_secret @@ -144,7 +146,7 @@ def __init__(self, jwks_url: str, algorithm: str = "RS256") -> None: super().__init__(algorithm) self._fetcher = JwksFetcher(jwks_url) - def _fetch_key(self, key_id: str | None = None) -> RSAPublicKey: + def _fetch_key(self, key_id: str) -> RSAPublicKey: return self._fetcher.get_key(key_id) diff --git a/auth0/rest.py b/auth0/rest.py index e1837669..41282b74 100644 --- a/auth0/rest.py +++ b/auth0/rest.py @@ -255,7 +255,7 @@ def _calculate_wait(self, attempt: int) -> int: wait = max(self.MIN_REQUEST_RETRY_DELAY(), wait) self._metrics["retries"] = attempt - self._metrics["backoff"].append(wait) + self._metrics["backoff"].append(wait) # type: ignore[attr-defined] return wait diff --git a/auth0/rest_async.py b/auth0/rest_async.py index 53b92840..183cfbb9 100644 --- a/auth0/rest_async.py +++ b/auth0/rest_async.py @@ -1,4 +1,3 @@ -# mypy: disable-error-code=override from __future__ import annotations import asyncio @@ -115,8 +114,8 @@ async def post( async def file_post( self, url: str, - data: dict[str, Any] | None = None, - files: dict[str, Any] | None = None, + data: dict[str, Any], + files: dict[str, Any], ) -> Any: headers = self.base_headers.copy() headers.pop("Content-Type", None) diff --git a/mypy.ini b/mypy.ini index f8bc1715..af08759b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -6,3 +6,9 @@ ignore_errors = True [mypy-auth0.management.*] ignore_errors = True + +[mypy-auth0.rest_async] +disable_error_code=override + +[mypy-auth0.authentication.async_token_verifier] +disable_error_code=override, misc, attr-defined