From 488797d902ab2452ee652b60f92c6e626c9e404d Mon Sep 17 00:00:00 2001 From: Eugen Ciur Date: Sat, 16 Nov 2024 09:24:47 +0100 Subject: [PATCH] remove jose dep (#43) --- auth_server/auth.py | 2 +- auth_server/main.py | 4 +-- poetry.lock | 83 ++++++++++----------------------------------- pyproject.toml | 2 +- 4 files changed, 22 insertions(+), 69 deletions(-) diff --git a/auth_server/auth.py b/auth_server/auth.py index f6c6f9e..3f31cc2 100644 --- a/auth_server/auth.py +++ b/auth_server/auth.py @@ -4,7 +4,7 @@ from sqlalchemy.exc import NoResultFound from datetime import datetime, timedelta, UTC -from jose import jwt +import jwt from passlib.hash import pbkdf2_sha256 from fastapi import HTTPException diff --git a/auth_server/main.py b/auth_server/main.py index cd291c7..8db60da 100644 --- a/auth_server/main.py +++ b/auth_server/main.py @@ -4,7 +4,7 @@ from sqlalchemy.exc import OperationalError, NoResultFound from fastapi import FastAPI, HTTPException, Response, Request, status, APIRouter from fastapi.security import OAuth2PasswordBearer -from jose import JWTError, jwt +import jwt from auth_server.auth import authenticate, create_token from auth_server.backends.oidc import introspect_token @@ -113,7 +113,7 @@ async def verify_endpoint(request: Request) -> Response: settings.papermerge__security__secret_key, algorithms=[settings.papermerge__security__token_algorithm], ) - except JWTError: + except jwt.DecodeError: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token", diff --git a/poetry.lock b/poetry.lock index 48dc629..dc16c96 100644 --- a/poetry.lock +++ b/poetry.lock @@ -87,24 +87,6 @@ idna = ["idna (>=3.7)"] trio = ["trio (>=0.23)"] wmi = ["wmi (>=1.5.1)"] -[[package]] -name = "ecdsa" -version = "0.19.0" -description = "ECDSA cryptographic signature library (pure python)" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.6" -files = [ - {file = "ecdsa-0.19.0-py2.py3-none-any.whl", hash = "sha256:2cea9b88407fdac7bbeca0833b189e4c9c53f2ef1e1eaa29f6224dbc809b707a"}, - {file = "ecdsa-0.19.0.tar.gz", hash = "sha256:60eaad1199659900dd0af521ed462b793bbdf867432b3948e87416ae4caf6bf8"}, -] - -[package.dependencies] -six = ">=1.9.0" - -[package.extras] -gmpy = ["gmpy"] -gmpy2 = ["gmpy2"] - [[package]] name = "email-validator" version = "2.2.0" @@ -720,6 +702,23 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] +[[package]] +name = "pyjwt" +version = "2.9.0" +description = "JSON Web Token implementation in Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "PyJWT-2.9.0-py3-none-any.whl", hash = "sha256:3b02fb0f44517787776cf48f2ae25d8e14f300e6d7545a4315cee571a415e850"}, + {file = "pyjwt-2.9.0.tar.gz", hash = "sha256:7e1e5b56cc735432a7369cbfa0efe50fa113ebecdc04ae6922deba8b84582d0c"}, +] + +[package.extras] +crypto = ["cryptography (>=3.4.0)"] +dev = ["coverage[toml] (==5.0.4)", "cryptography (>=3.4.0)", "pre-commit", "pytest (>=6.0.0,<7.0.0)", "sphinx", "sphinx-rtd-theme", "zope.interface"] +docs = ["sphinx", "sphinx-rtd-theme", "zope.interface"] +tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"] + [[package]] name = "pytest" version = "7.4.4" @@ -771,27 +770,6 @@ files = [ [package.extras] cli = ["click (>=5.0)"] -[[package]] -name = "python-jose" -version = "3.3.0" -description = "JOSE implementation in Python" -optional = false -python-versions = "*" -files = [ - {file = "python-jose-3.3.0.tar.gz", hash = "sha256:55779b5e6ad599c6336191246e95eb2293a9ddebd555f796a65f838f07e5d78a"}, - {file = "python_jose-3.3.0-py2.py3-none-any.whl", hash = "sha256:9b1376b023f8b298536eedd47ae1089bcdb848f1535ab30555cd92002d78923a"}, -] - -[package.dependencies] -ecdsa = "!=0.15" -pyasn1 = "*" -rsa = "*" - -[package.extras] -cryptography = ["cryptography (>=3.4.0)"] -pycrypto = ["pyasn1", "pycrypto (>=2.6.0,<2.7.0)"] -pycryptodome = ["pyasn1", "pycryptodome (>=3.3.1,<4.0.0)"] - [[package]] name = "python-multipart" version = "0.0.17" @@ -883,20 +861,6 @@ pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] -[[package]] -name = "rsa" -version = "4.9" -description = "Pure-Python RSA implementation" -optional = false -python-versions = ">=3.6,<4" -files = [ - {file = "rsa-4.9-py3-none-any.whl", hash = "sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7"}, - {file = "rsa-4.9.tar.gz", hash = "sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21"}, -] - -[package.dependencies] -pyasn1 = ">=0.1.3" - [[package]] name = "shellingham" version = "1.5.4" @@ -908,17 +872,6 @@ files = [ {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, ] -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - [[package]] name = "sniffio" version = "1.3.1" @@ -1353,4 +1306,4 @@ pg = ["psycopg2"] [metadata] lock-version = "2.0" python-versions = "^3.13" -content-hash = "18be74d3d9372b572b3f354735f8d16cf9f664494211b162fda0b227a9cb2691" +content-hash = "bb87cf7e828a6f663c2c33b0966cfed23168a695527404649abfde9c830b0303" diff --git a/pyproject.toml b/pyproject.toml index eccdb4d..b3e277c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ python = "^3.13" fastapi = {extras = ["standard"], version = "^0.115"} sqlalchemy = "^2.0.9" passlib = "^1.7.4" -python-jose = "^3.3.0" python-multipart = "^0.0.17" httpx = "^0.27" rich = "^13.3.5" @@ -21,6 +20,7 @@ ldap3 = "^2.9.1" typer = "^0.13.0" psycopg2 = { version = "^2.9", optional = true} mysqlclient = {version = "^2.2", optional = true} +pyjwt = "^2.9.0" [tool.poetry.extras] pg = ["psycopg2"]