Properly fail to wrong Authorization token type

This commit is contained in:
Pierre Dulac 2013-03-02 20:17:14 +01:00
parent 8809c46ab5
commit c449dd4f4d

View File

@ -176,7 +176,7 @@ class OAuth2Authentication(BaseAuthentication):
""" """
auth = request.META.get('HTTP_AUTHORIZATION', '').split() auth = request.META.get('HTTP_AUTHORIZATION', '').split()
if not auth or auth[0].lower() != "bearer": if not auth or auth[0].lower() != "bearer":
return None raise exceptions.AuthenticationFailed('Invalid Authorization token type')
if len(auth) != 2: if len(auth) != 2:
raise exceptions.AuthenticationFailed('Invalid token header') raise exceptions.AuthenticationFailed('Invalid token header')
@ -212,8 +212,6 @@ class OAuth2Authentication(BaseAuthentication):
raise exceptions.AuthenticationFailed( raise exceptions.AuthenticationFailed(
'You are not allowed to access this resource.') 'You are not allowed to access this resource.')
return None
def authenticate_header(self, request): def authenticate_header(self, request):
""" """
Bearer is the only finalized type currently Bearer is the only finalized type currently