djangosnippets.org: Latest snippets posted by joshsharphttps://djangosnippets.org/users/joshsharp/2011-06-22T00:50:02.789997-05:00joshsharpBasic Auth Middleware
2011-06-22T00:50:02.789997-05:00joshsharphttps://djangosnippets.org/snippets/2468/<p>A very basic Basic Auth middleware that uses a username/password defined in your settings.py as <code>BASICAUTH_USERNAME</code> and <code>BASICAUTH_PASSWORD</code>. Does not use Django auth. Handy for quickly securing an entire site during development, for example.</p>
<p>In settings.py:</p>
<pre><code>BASICAUTH_USERNAME = 'user'
BASICAUTH_PASSWORD = 'pass'
MIDDLEWARE_CLASSES = (
'app.module.BasicAuthMiddleware',
#all other middleware …</code></pre>
Freely redistributable