diff --git a/fastapi_jwt_auth/auth_jwt.py b/fastapi_jwt_auth/auth_jwt.py index 4110bdb..de1f96a 100644 --- a/fastapi_jwt_auth/auth_jwt.py +++ b/fastapi_jwt_auth/auth_jwt.py @@ -191,7 +191,7 @@ def _create_token( secret_key, algorithm=algorithm, headers=headers - ).decode('utf-8') + ) def _has_token_in_denylist_callback(self) -> bool: """ diff --git a/pyproject.toml b/pyproject.toml index 6c4acab..30f8ce3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ requires = [ "fastapi>=0.61.0", - "PyJWT>=1.7.1,<2.0.0" + "PyJWT>=2.0.0,<3.0.0" ] description-file = "README.md" @@ -47,8 +47,8 @@ doc = [ ] dev = [ - "cryptography>=2.6,<4.0.0", + "cryptography>=3.0,<36.0.0", "uvicorn>=0.11.5,<0.12.0" ] -asymmetric = ["cryptography>=2.6,<4.0.0"] +asymmetric = ["cryptography>=3.0,<36.0.0"] diff --git a/tests/test_decode_token.py b/tests/test_decode_token.py index 5344d48..38e367a 100644 --- a/tests/test_decode_token.py +++ b/tests/test_decode_token.py @@ -51,7 +51,7 @@ def default_access_token(): @pytest.fixture(scope='function') def encoded_token(default_access_token): - return jwt.encode(default_access_token,'secret-key',algorithm='HS256').decode('utf-8') + return jwt.encode(default_access_token,'secret-key',algorithm='HS256') def test_verified_token(client,encoded_token,Authorize): class SettingsOne(BaseSettings): @@ -67,7 +67,7 @@ def get_settings_one(): assert response.status_code == 422 assert response.json() == {'detail': 'Not enough segments'} # InvalidSignatureError - token = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256').decode('utf-8') + token = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256') response = client.get('/protected',headers={"Authorization":f"Bearer {token}"}) assert response.status_code == 422 assert response.json() == {'detail': 'Signature verification failed'} @@ -78,7 +78,7 @@ def get_settings_one(): assert response.status_code == 422 assert response.json() == {'detail': 'Signature has expired'} # InvalidAlgorithmError - token = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS384').decode('utf-8') + token = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS384') response = client.get('/protected',headers={"Authorization":f"Bearer {token}"}) assert response.status_code == 422 assert response.json() == {'detail': 'The specified alg value is not allowed'}