You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
691 B

from rest_framework import authentication
from edivorce.apps.core.models import BceidUser
class BCeIDAuthentication(authentication.BaseAuthentication):
"""
Make the DRF user the BCeID user populated in our middleware, to avoid DRF
overwriting our user for API calls.
This relies on our middleware entirely for authentication.
"""
def authenticate(self, request):
try:
request.user = request._user # pylint: disable=protected-access
except:
request.user = request._request.user # pylint: disable=protected-access
return (request.user, None)
def get_user(self, pk):
return BceidUser.objects.get(pk=pk)