mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Properly fail to wrong Authorization token type
This commit is contained in:
parent
8809c46ab5
commit
c449dd4f4d
|
@ -176,7 +176,7 @@ class OAuth2Authentication(BaseAuthentication):
|
|||
"""
|
||||
auth = request.META.get('HTTP_AUTHORIZATION', '').split()
|
||||
if not auth or auth[0].lower() != "bearer":
|
||||
return None
|
||||
raise exceptions.AuthenticationFailed('Invalid Authorization token type')
|
||||
|
||||
if len(auth) != 2:
|
||||
raise exceptions.AuthenticationFailed('Invalid token header')
|
||||
|
@ -212,8 +212,6 @@ class OAuth2Authentication(BaseAuthentication):
|
|||
raise exceptions.AuthenticationFailed(
|
||||
'You are not allowed to access this resource.')
|
||||
|
||||
return None
|
||||
|
||||
def authenticate_header(self, request):
|
||||
"""
|
||||
Bearer is the only finalized type currently
|
||||
|
|
Loading…
Reference in New Issue
Block a user