Skip to content
Snippets Groups Projects
permissions.py 322 B
Newer Older
  • Learn to ignore specific revisions
  • from django.conf import settings
    
    from rest_framework.permissions import BasePermission
    
    
    class ConditionalAuthentication(BasePermission):
    
        def has_permission(self, request, view):
            if settings.API_AUTHENTICATION_REQUIRED:
                return request.user and request.user.is_authenticated()
            return True