Skip to content

Instantly share code, notes, and snippets.

@maxpoletaev
Created February 11, 2018 17:15
Show Gist options
  • Save maxpoletaev/404b2076920697451fe7db5d459c1f22 to your computer and use it in GitHub Desktop.
Save maxpoletaev/404b2076920697451fe7db5d459c1f22 to your computer and use it in GitHub Desktop.
from rest_framework.authentication import BaseAuthentication
class SessionAuthenticationWithoutCsrf(BaseAuthentication):
def authenticate(self, request):
request = request._request
user = getattr(request, 'user', None)
if not user or not user.is_active:
return None
return (user, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment