mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Bump pyjwt from 2.8.0 to 2.9.0 (#2374)
* Bump pyjwt from 2.8.0 to 2.9.0 Bumps [pyjwt](https://github.com/jpadilla/pyjwt) from 2.8.0 to 2.9.0. - [Release notes](https://github.com/jpadilla/pyjwt/releases) - [Changelog](https://github.com/jpadilla/pyjwt/blob/master/CHANGELOG.rst) - [Commits](https://github.com/jpadilla/pyjwt/compare/2.8.0...2.9.0) --- updated-dependencies: - dependency-name: pyjwt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update pyjwt==2.9.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
43cb027592
commit
da501df846
8 changed files with 102 additions and 87 deletions
|
@ -3,9 +3,8 @@ from __future__ import annotations
|
|||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import sys
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import TYPE_CHECKING, Any, ClassVar, NoReturn, Union, cast, overload
|
||||
from typing import TYPE_CHECKING, Any, ClassVar, Literal, NoReturn, cast, overload
|
||||
|
||||
from .exceptions import InvalidKeyError
|
||||
from .types import HashlibHash, JWKDict
|
||||
|
@ -21,14 +20,8 @@ from .utils import (
|
|||
to_base64url_uint,
|
||||
)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
|
||||
try:
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives.asymmetric import padding
|
||||
|
@ -194,18 +187,16 @@ class Algorithm(ABC):
|
|||
@overload
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def to_jwk(key_obj, as_dict: Literal[True]) -> JWKDict:
|
||||
... # pragma: no cover
|
||||
def to_jwk(key_obj, as_dict: Literal[True]) -> JWKDict: ... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def to_jwk(key_obj, as_dict: Literal[False] = False) -> str:
|
||||
... # pragma: no cover
|
||||
def to_jwk(key_obj, as_dict: Literal[False] = False) -> str: ... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def to_jwk(key_obj, as_dict: bool = False) -> Union[JWKDict, str]:
|
||||
def to_jwk(key_obj, as_dict: bool = False) -> JWKDict | str:
|
||||
"""
|
||||
Serializes a given key into a JWK
|
||||
"""
|
||||
|
@ -274,16 +265,18 @@ class HMACAlgorithm(Algorithm):
|
|||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: str | bytes, as_dict: Literal[True]) -> JWKDict:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key_obj: str | bytes, as_dict: Literal[True]
|
||||
) -> JWKDict: ... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: str | bytes, as_dict: Literal[False] = False) -> str:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key_obj: str | bytes, as_dict: Literal[False] = False
|
||||
) -> str: ... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: str | bytes, as_dict: bool = False) -> Union[JWKDict, str]:
|
||||
def to_jwk(key_obj: str | bytes, as_dict: bool = False) -> JWKDict | str:
|
||||
jwk = {
|
||||
"k": base64url_encode(force_bytes(key_obj)).decode(),
|
||||
"kty": "oct",
|
||||
|
@ -350,22 +343,25 @@ if has_crypto:
|
|||
RSAPrivateKey, load_pem_private_key(key_bytes, password=None)
|
||||
)
|
||||
except ValueError:
|
||||
return cast(RSAPublicKey, load_pem_public_key(key_bytes))
|
||||
try:
|
||||
return cast(RSAPublicKey, load_pem_public_key(key_bytes))
|
||||
except (ValueError, UnsupportedAlgorithm):
|
||||
raise InvalidKeyError("Could not parse the provided public key.")
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: AllowedRSAKeys, as_dict: Literal[True]) -> JWKDict:
|
||||
... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: AllowedRSAKeys, as_dict: Literal[False] = False) -> str:
|
||||
... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def to_jwk(
|
||||
key_obj: AllowedRSAKeys, as_dict: bool = False
|
||||
) -> Union[JWKDict, str]:
|
||||
key_obj: AllowedRSAKeys, as_dict: Literal[True]
|
||||
) -> JWKDict: ... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(
|
||||
key_obj: AllowedRSAKeys, as_dict: Literal[False] = False
|
||||
) -> str: ... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: AllowedRSAKeys, as_dict: bool = False) -> JWKDict | str:
|
||||
obj: dict[str, Any] | None = None
|
||||
|
||||
if hasattr(key_obj, "private_numbers"):
|
||||
|
@ -533,7 +529,7 @@ if has_crypto:
|
|||
|
||||
return der_to_raw_signature(der_sig, key.curve)
|
||||
|
||||
def verify(self, msg: bytes, key: "AllowedECKeys", sig: bytes) -> bool:
|
||||
def verify(self, msg: bytes, key: AllowedECKeys, sig: bytes) -> bool:
|
||||
try:
|
||||
der_sig = raw_to_der_signature(sig, key.curve)
|
||||
except ValueError:
|
||||
|
@ -552,18 +548,18 @@ if has_crypto:
|
|||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: AllowedECKeys, as_dict: Literal[True]) -> JWKDict:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key_obj: AllowedECKeys, as_dict: Literal[True]
|
||||
) -> JWKDict: ... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key_obj: AllowedECKeys, as_dict: Literal[False] = False) -> str:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key_obj: AllowedECKeys, as_dict: Literal[False] = False
|
||||
) -> str: ... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def to_jwk(
|
||||
key_obj: AllowedECKeys, as_dict: bool = False
|
||||
) -> Union[JWKDict, str]:
|
||||
def to_jwk(key_obj: AllowedECKeys, as_dict: bool = False) -> JWKDict | str:
|
||||
if isinstance(key_obj, EllipticCurvePrivateKey):
|
||||
public_numbers = key_obj.public_key().public_numbers()
|
||||
elif isinstance(key_obj, EllipticCurvePublicKey):
|
||||
|
@ -771,16 +767,18 @@ if has_crypto:
|
|||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key: AllowedOKPKeys, as_dict: Literal[True]) -> JWKDict:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key: AllowedOKPKeys, as_dict: Literal[True]
|
||||
) -> JWKDict: ... # pragma: no cover
|
||||
|
||||
@overload
|
||||
@staticmethod
|
||||
def to_jwk(key: AllowedOKPKeys, as_dict: Literal[False] = False) -> str:
|
||||
... # pragma: no cover
|
||||
def to_jwk(
|
||||
key: AllowedOKPKeys, as_dict: Literal[False] = False
|
||||
) -> str: ... # pragma: no cover
|
||||
|
||||
@staticmethod
|
||||
def to_jwk(key: AllowedOKPKeys, as_dict: bool = False) -> Union[JWKDict, str]:
|
||||
def to_jwk(key: AllowedOKPKeys, as_dict: bool = False) -> JWKDict | str:
|
||||
if isinstance(key, (Ed25519PublicKey, Ed448PublicKey)):
|
||||
x = key.public_bytes(
|
||||
encoding=Encoding.Raw,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue