mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 05:29:17 +02:00
Fixed #15 again, now check authorization also using query param
This commit is contained in:
parent
795cd7beb9
commit
3ccb70d0a8
9 changed files with 98 additions and 8 deletions
20
api/funkwhale_api/common/authentication.py
Normal file
20
api/funkwhale_api/common/authentication.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue