Skip to content

Instantly share code, notes, and snippets.

@dstufft
Created August 1, 2011 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstufft/1117376 to your computer and use it in GitHub Desktop.
Save dstufft/1117376 to your computer and use it in GitHub Desktop.
from tastypie.authentication import BasicAuthentication as TastypieBasicAuthentcation
from django.contrib.auth.models import AnonymousUser
class BasicAuthentication(TastypieBasicAuthentcation):
"""
Subclass Basic Authentcation to allow Anonymous users.
"""
def is_authenticated(self, request, **kwargs):
print request.user
if not request.META.get("HTTP_AUTHORIZATION"):
if request.method == "GET":
return True
return super(BasicAuthentication, self).is_authenticated(request, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment