Fixed #15 again, now check authorization also using query param

This commit is contained in:
Eliot Berriot 2017-06-29 02:27:35 +02:00
parent 795cd7beb9
commit 3ccb70d0a8
9 changed files with 98 additions and 8 deletions

View file

@ -0,0 +1,20 @@
from rest_framework import exceptions
from rest_framework_jwt import authentication
from rest_framework_jwt.settings import api_settings
class JSONWebTokenAuthenticationQS(
authentication.BaseJSONWebTokenAuthentication):
www_authenticate_realm = 'api'
def get_jwt_value(self, request):
token = request.query_params.get('jwt')
if 'jwt' in request.query_params and not token:
msg = _('Invalid Authorization header. No credentials provided.')
raise exceptions.AuthenticationFailed(msg)
return token
def authenticate_header(self, request):
return '{0} realm="{1}"'.format(
api_settings.JWT_AUTH_HEADER_PREFIX, self.www_authenticate_realm)