Skip to content
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

Python jwt upgrade #26

Open
wants to merge 4 commits 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 jwt_auth/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def authenticate(self, request):

try:
payload = jwt_decode_handler(auth[1])
except jwt.ExpiredSignature:
except jwt.ExpiredSignatureError:
msg = 'Signature has expired.'
raise exceptions.AuthenticationFailed(msg)
except jwt.DecodeError:
Expand Down
5 changes: 3 additions & 2 deletions jwt_auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ def jwt_encode_handler(payload):
payload,
settings.JWT_SECRET_KEY,
settings.JWT_ALGORITHM
).decode('utf-8')
)


def jwt_decode_handler(token):
from jwt_auth import settings

options = {
'verify_exp': settings.JWT_VERIFY_EXPIRATION,
'verify_signature': settings.JWT_VERIFY
}

return jwt.decode(
token,
settings.JWT_SECRET_KEY,
settings.JWT_VERIFY,
algorithms=[settings.JWT_ALGORITHM],
options=options,
leeway=settings.JWT_LEEWAY
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PyJWT>=1.4.0,<2.0.0
PyJWT>=1.4.0,<=2.5.0