Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DjangoAuthentication(Authentication):
- def is_authenticated(self, request, **kwargs):
- if request.user.is_authenticated():
- return True
- elif 'HTTP_AUTHORIZATION' in request.META:
- import base64
- auth = request.META['HTTP_AUTHORIZATION'].split()
- if len(auth) == 2:
- if auth[0].lower() == "basic":
- uname, passwd = base64.b64decode(auth[1]).split(':')
- user = authenticate(username=uname, password=passwd)
- if user is not None:
- if user.is_active:
- login(request, user)
- request.user = user
- return True
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement