Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created July 9, 2012 21:28
Show Gist options
  • Save jacobian/3079065 to your computer and use it in GitHub Desktop.
Save jacobian/3079065 to your computer and use it in GitHub Desktop.
Auth a whole django site
import os
import barrel
REALM = "PRIVATE"
USERS = [('jacob', 'hunter2')]
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = barrel.cooper.basicauth(users=USERS, realm=REALM)(get_wsgi_application())
@pydanny
Copy link

pydanny commented Jul 9, 2012

Fixed and stick into the wsgi.py file of your django project:

from barrel import cooper

REALM = "PRIVATE"
USERS = [('stupid', 'idiot')]

application = cooper.basicauth(users=USERS, realm=REALM)(get_wsgi_application())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment