Skip to content

Update PyJWT to 2.3.0 and cryptography to 35.0.0 #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastapi_jwt_auth/auth_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _create_token(
secret_key,
algorithm=algorithm,
headers=headers
).decode('utf-8')
)

def _has_token_in_denylist_callback(self) -> bool:
"""
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
6 changes: 3 additions & 3 deletions tests/test_decode_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'}
Expand All @@ -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'}
Expand Down