mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Update pyjwt==2.3.0
This commit is contained in:
parent
973cad264f
commit
d981f6e51f
3 changed files with 18 additions and 19 deletions
|
@ -25,7 +25,7 @@ from .exceptions import (
|
||||||
)
|
)
|
||||||
from .jwks_client import PyJWKClient
|
from .jwks_client import PyJWKClient
|
||||||
|
|
||||||
__version__ = "2.2.0"
|
__version__ = "2.3.0"
|
||||||
|
|
||||||
__title__ = "PyJWT"
|
__title__ = "PyJWT"
|
||||||
__description__ = "JSON Web Token implementation in Python"
|
__description__ = "JSON Web Token implementation in Python"
|
||||||
|
|
|
@ -113,14 +113,14 @@ class PyJWS:
|
||||||
key = alg_obj.prepare_key(key)
|
key = alg_obj.prepare_key(key)
|
||||||
signature = alg_obj.sign(signing_input, key)
|
signature = alg_obj.sign(signing_input, key)
|
||||||
|
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
if not has_crypto and algorithm in requires_cryptography:
|
if not has_crypto and algorithm in requires_cryptography:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"Algorithm '%s' could not be found. Do you have cryptography "
|
"Algorithm '%s' could not be found. Do you have cryptography "
|
||||||
"installed?" % algorithm
|
"installed?" % algorithm
|
||||||
)
|
) from e
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Algorithm not supported")
|
raise NotImplementedError("Algorithm not supported") from e
|
||||||
|
|
||||||
segments.append(base64url_encode(signature))
|
segments.append(base64url_encode(signature))
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ class PyJWS:
|
||||||
key: str = "",
|
key: str = "",
|
||||||
algorithms: List[str] = None,
|
algorithms: List[str] = None,
|
||||||
options: Dict = None,
|
options: Dict = None,
|
||||||
|
**kwargs,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
if options is None:
|
if options is None:
|
||||||
options = {}
|
options = {}
|
||||||
|
@ -162,8 +163,9 @@ class PyJWS:
|
||||||
key: str = "",
|
key: str = "",
|
||||||
algorithms: List[str] = None,
|
algorithms: List[str] = None,
|
||||||
options: Dict = None,
|
options: Dict = None,
|
||||||
|
**kwargs,
|
||||||
) -> str:
|
) -> str:
|
||||||
decoded = self.decode_complete(jwt, key, algorithms, options)
|
decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
|
||||||
return decoded["payload"]
|
return decoded["payload"]
|
||||||
|
|
||||||
def get_unverified_header(self, jwt):
|
def get_unverified_header(self, jwt):
|
||||||
|
@ -236,8 +238,8 @@ class PyJWS:
|
||||||
if not alg_obj.verify(signing_input, key, signature):
|
if not alg_obj.verify(signing_input, key, signature):
|
||||||
raise InvalidSignatureError("Signature verification failed")
|
raise InvalidSignatureError("Signature verification failed")
|
||||||
|
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
raise InvalidAlgorithmError("Algorithm not supported")
|
raise InvalidAlgorithmError("Algorithm not supported") from e
|
||||||
|
|
||||||
def _validate_headers(self, headers):
|
def _validate_headers(self, headers):
|
||||||
if "kid" in headers:
|
if "kid" in headers:
|
||||||
|
|
|
@ -68,9 +68,7 @@ class PyJWT:
|
||||||
key: str = "",
|
key: str = "",
|
||||||
algorithms: List[str] = None,
|
algorithms: List[str] = None,
|
||||||
options: Dict = None,
|
options: Dict = None,
|
||||||
audience: Optional[Union[str, List[str]]] = None,
|
**kwargs,
|
||||||
issuer: Optional[str] = None,
|
|
||||||
leeway: Union[float, timedelta] = 0,
|
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
if options is None:
|
if options is None:
|
||||||
options = {"verify_signature": True}
|
options = {"verify_signature": True}
|
||||||
|
@ -94,6 +92,7 @@ class PyJWT:
|
||||||
key=key,
|
key=key,
|
||||||
algorithms=algorithms,
|
algorithms=algorithms,
|
||||||
options=options,
|
options=options,
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -104,7 +103,7 @@ class PyJWT:
|
||||||
raise DecodeError("Invalid payload string: must be a json object")
|
raise DecodeError("Invalid payload string: must be a json object")
|
||||||
|
|
||||||
merged_options = {**self.options, **options}
|
merged_options = {**self.options, **options}
|
||||||
self._validate_claims(payload, merged_options, audience, issuer, leeway)
|
self._validate_claims(payload, merged_options, **kwargs)
|
||||||
|
|
||||||
decoded["payload"] = payload
|
decoded["payload"] = payload
|
||||||
return decoded
|
return decoded
|
||||||
|
@ -115,20 +114,18 @@ class PyJWT:
|
||||||
key: str = "",
|
key: str = "",
|
||||||
algorithms: List[str] = None,
|
algorithms: List[str] = None,
|
||||||
options: Dict = None,
|
options: Dict = None,
|
||||||
audience: Optional[Union[str, List[str]]] = None,
|
**kwargs,
|
||||||
issuer: Optional[str] = None,
|
|
||||||
leeway: Union[float, timedelta] = 0,
|
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
decoded = self.decode_complete(
|
decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
|
||||||
jwt, key, algorithms, options, audience, issuer, leeway
|
|
||||||
)
|
|
||||||
return decoded["payload"]
|
return decoded["payload"]
|
||||||
|
|
||||||
def _validate_claims(self, payload, options, audience, issuer, leeway):
|
def _validate_claims(
|
||||||
|
self, payload, options, audience=None, issuer=None, leeway=0, **kwargs
|
||||||
|
):
|
||||||
if isinstance(leeway, timedelta):
|
if isinstance(leeway, timedelta):
|
||||||
leeway = leeway.total_seconds()
|
leeway = leeway.total_seconds()
|
||||||
|
|
||||||
if not isinstance(audience, (str, type(None), Iterable)):
|
if not isinstance(audience, (bytes, str, type(None), Iterable)):
|
||||||
raise TypeError("audience must be a string, iterable, or None")
|
raise TypeError("audience must be a string, iterable, or None")
|
||||||
|
|
||||||
self._validate_required_claims(payload, options)
|
self._validate_required_claims(payload, options)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue