django-grpc
django-grpc copied to clipboard
how to implements django auth
It would be great to integrate with django authentication system. Feel free to open pull request
One super simple way is to create an auth wrapper and wrap the methods that require it
from django.http import HttpRequest
from django.contrib.auth.middleware import AuthenticationMiddleware
class requires_authentication(object):
def __call__(self, f):
async def authenticate(s, stream):
request = HttpRequest()
request.META = dict(stream.metadata)
AuthenticationMiddleware.process_request(request)
return await f(s, stream)
return authenticate