File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11# coding: utf-8
22from __future__ import absolute_import , unicode_literals
33
4- import jwt
4+ import jwt . exceptions
55from django .utils .encoding import smart_text
66from django .utils .translation import ugettext as _
77from rest_framework import exceptions
@@ -47,13 +47,16 @@ def authenticate(self, request):
4747
4848 try :
4949 payload = decode_jwt_token (token = token )
50- except jwt .ExpiredSignature :
50+ except jwt .exceptions . ExpiredSignature :
5151 msg = _ ('Signature has expired.' )
5252 raise exceptions .AuthenticationFailed (msg )
53- except jwt .DecodeError :
53+ except jwt .exceptions . DecodeError :
5454 msg = _ ('Error decoding signature.' )
5555 raise exceptions .AuthenticationFailed (msg )
56- except jwt .InvalidTokenError :
56+ except jwt .exceptions .InvalidKeyError :
57+ msg = _ ('Unauthorized token signing key.' )
58+ raise exceptions .AuthenticationFailed (msg )
59+ except jwt .exceptions .InvalidTokenError :
5760 raise exceptions .AuthenticationFailed ()
5861
5962 return self .authenticate_credentials (payload = payload )
You can’t perform that action at this time.
0 commit comments