The other day I released bpssl which is a Django application that helps you support HTTPS on your website. The main functionality is performing redirection for HTTPS only URLs and views. For instance, if a request for your login view '/login' is recieved over HTTP, the provided middleware can redirect the user to the equivalent HTTPS page.

Specifying views and urls as secure is supported as are flatpages. Fastcgi and HTTP proxy setups are also well supported.

Many people support this at the web server level but the pages that require SSL can change often and it is often easier to manage this at the application layer.

bpssl draws inspiration from the well known SSL Middleware snippets on . It roughly supports the features of the following snippets:

For the lazy


First install the bpssl package using PIP:

$ pip install bpssl

or easy_install:

$ easy_install bpssl

Next add 'beproud.django.ssl' to your INSTALLED_APPS in your

    # ...
    # ...

Next add 'beproud.django.ssl.middleware.SSLRedirectMiddleware' to your MIDDLEWARE_CLASSES setting.

    # ...
    # ...

Finally add SSL_URLS to your settings. SSL_URLS is a list of regular expressions that match Urls.

    # ...

Or if you prefer:

# In the age of Firesheep, you can never be too careful.

There is also a ssl_view() decorator which allows you to attach redirection logic to individual views.

On the Django side this is all you need to setup and run bpssl. There is some setup required on the web server depending on your setup. Please check out the Documentation or Source Code for details.