Adding HTTP Auth to Django

It’s sometimes useful to add HTTP auth to staging sites to stop search engine bots and others taking a sneek peek behind the scenes before your ready. It’s supprising how easily staging sites can get picked up, but HTTP auth is a simple way to put a stop to it.

Django doesn’t have this feature by default and rather than hacking it’s middleware, a simple WSGI app Barrel can be used to wrap the main application: