Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix after bump pyjwt

Damian Wdd7645344cb3
diff --git a/requirements.txt b/requirements.txt
index 0727fa177d..a845f7919a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -98,7 +98,7 @@ purl==1.5
pyasn1-modules==0.2.8; python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.6.0"
pyasn1==0.4.8; python_version >= "3.5" and python_full_version < "3.0.0" and python_version < "4" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0") or python_version >= "3.5" and python_full_version >= "3.6.0" and python_version < "4" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.6.0")
pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
-pyjwt==1.7.1
+pyjwt==2.0.0
pyphen==0.10.0; python_version >= "3.6"
python-dateutil==2.8.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
python-dotenv==0.15.0
diff --git a/requirements_dev.txt b/requirements_dev.txt
index 8791e9a90b..12541093d7 100644
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@ -137,7 +137,7 @@ pycodestyle==2.6.0; (python_version >= "2.7" and python_full_version < "3.0.0")
pycparser==2.20; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
pydocstyle==5.1.1; python_version >= "3.5"
pyflakes==2.2.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
-pyjwt==1.7.1
+pyjwt==2.0.0
pylint-celery==0.3
pylint-django==2.4.0
pylint-plugin-utils==0.6
diff --git a/saleor/core/jwt.py b/saleor/core/jwt.py
index aeed424edb..9de9b32bfa 100644
--- a/saleor/core/jwt.py
+++ b/saleor/core/jwt.py
@@ -54,14 +54,14 @@ def jwt_encode(payload: Dict[str, Any]) -> str:
payload,
settings.SECRET_KEY, # type: ignore
JWT_ALGORITHM,
- ).decode("utf-8")
+ )
def jwt_decode(token: str) -> Dict[str, Any]:
return jwt.decode(
token,
settings.SECRET_KEY, # type: ignore
- algorithms=JWT_ALGORITHM,
+ algorithms=[JWT_ALGORITHM],
verify_expiration=settings.JWT_EXPIRE,
)
diff --git a/saleor/core/tests/test_auth_backend.py b/saleor/core/tests/test_auth_backend.py
index 88116b4cbb..e19cee43ba 100644
--- a/saleor/core/tests/test_auth_backend.py
+++ b/saleor/core/tests/test_auth_backend.py
@@ -53,7 +53,7 @@ def test_incorrect_token(rf, staff_user, settings):
payload,
"Wrong secret",
JWT_ALGORITHM,
- ).decode("utf-8")
+ )
request = rf.request(HTTP_AUTHORIZATION=f"JWT {token}")
backend = JSONWebTokenBackend()
with pytest.raises(InvalidSignatureError):
diff --git a/saleor/graphql/account/mutations/jwt.py b/saleor/graphql/account/mutations/jwt.py
index 1af709cf41..e6c49d01e5 100644
--- a/saleor/graphql/account/mutations/jwt.py
+++ b/saleor/graphql/account/mutations/jwt.py
@@ -29,7 +29,7 @@ from ..types import User
def get_payload(token):
try:
payload = jwt_decode(token)
- except jwt.ExpiredSignature:
+ except jwt.ExpiredSignatureError:
raise ValidationError(
"Signature has expired", code=AccountErrorCode.JWT_SIGNATURE_EXPIRED.value
)