I want to create global authentication with middleware django restframework which check every request user authenticate or not.
I don't want to add code on every view class like this
@permission_classes([IsAuthenticated]) class UserProfile(APIView):
I want to create global authentication with middleware django restframework which check every request user authenticate or not.
I don't want to add code on every view class like this
@permission_classes([IsAuthenticated]) class UserProfile(APIView):
You just need to set the permissions policy for DRF in your settings.py file. Here the Docs
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
]
}