Skip to content

Commit 6c570d9

Browse files
committed
[DOP-23122] Replace python-jose with pyjwt
1 parent 950b23b commit 6c570d9

File tree

5 files changed

+31
-107
lines changed

5 files changed

+31
-107
lines changed

poetry.lock

Lines changed: 24 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fastapi = { version = "^0.115", optional = true}
5555
asgi-correlation-id = {version = "^4.3.4", optional = true}
5656
uvicorn = { version = ">=0.30.6,<0.35.0", optional = true }
5757
alembic = { version = "^1.13.2", optional = true }
58-
python-jose = { version = "^3.3.0", extras = ["cryptography"], optional = true }
58+
pyjwt = { version = "^2.10.1", optional = true }
5959
jinja2 = { version = "^3.1.4", optional = true }
6060
python-multipart = { version = ">=0.0.9,<0.0.21", optional = true }
6161
celery = { version = "^5.4.0", optional = true }
@@ -82,7 +82,7 @@ server = [
8282
"uvicorn",
8383
"alembic",
8484
"python-multipart",
85-
"python-jose",
85+
"pyjwt",
8686
"asgi-correlation-id",
8787
"jinja2",
8888
"psycopg",
@@ -100,8 +100,6 @@ worker = [
100100
"pydantic-settings",
101101
"sqlalchemy",
102102
"sqlalchemy-utils",
103-
"python-multipart",
104-
"python-jose",
105103
"celery",
106104
"onetl",
107105
"asgi-correlation-id",
@@ -119,8 +117,6 @@ scheduler = [
119117
"sqlalchemy",
120118
"sqlalchemy-utils",
121119
"asyncpg",
122-
"python-multipart",
123-
"python-jose",
124120
"pyyaml",
125121
"coloredlogs",
126122
"python-json-logger",
@@ -148,7 +144,6 @@ black = "^24.8.0"
148144
flake8 = "^7.0.0"
149145
flake8-pyproject = "^1.2.3"
150146
sqlalchemy = {extras = ["mypy"], version = "^2.0.35"}
151-
types-python-jose = "^3.3.4.20240106"
152147

153148
[tool.poetry.group.docs.dependencies]
154149
autodoc-pydantic = {version = "^2.2.0", python = ">=3.8"}

syncmaster/server/settings/auth/jwt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class JWTSettings(BaseModel):
3333
"""
3434
Algorithm used for signing JWT tokens.
3535
36-
See `python-jose <https://python-jose.readthedocs.io/en/latest/jws/index.html#supported-algorithms>`_
36+
See `pyjwt <https://pyjwt.readthedocs.io/en/latest/algorithms.html>`_
3737
documentation.
3838
""",
3939
),

syncmaster/server/utils/jwt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2023-2024 MTS PJSC
22
# SPDX-License-Identifier: Apache-2.0
33

4-
from jose import ExpiredSignatureError, JWTError, jwt
4+
import jwt
55

66
from syncmaster.exceptions.auth import AuthorizationError
77

@@ -22,8 +22,8 @@ def decode_jwt(token: str, secret_key: str, security_algorithm: str) -> dict:
2222
algorithms=[security_algorithm],
2323
)
2424
if "exp" not in result:
25-
raise ExpiredSignatureError("Missing expiration time in token")
25+
raise jwt.ExpiredSignatureError("Missing expiration time in token")
2626

2727
return result
28-
except JWTError as e:
28+
except jwt.PyJWTError as e:
2929
raise AuthorizationError("Invalid token") from e

tests/test_unit/test_auth/auth_fixtures/keycloak_fixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import time
33
from base64 import b64encode
44

5+
import jwt
56
import pytest
67
import responses
78
from cryptography.hazmat.primitives import serialization
89
from cryptography.hazmat.primitives.asymmetric import rsa
910
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
1011
from itsdangerous import TimestampSigner
11-
from jose import jwt
1212

1313

1414
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)