commonlib icon indicating copy to clipboard operation
commonlib copied to clipboard

Sniff the scheme in FullyQualifiedRedirectMiddleware rather than hardcoding it to http

Open stevenday opened this issue 12 years ago • 0 comments

I've add a method to FullyQualifiedRedirectMiddleware which sniffs the scheme from the request and then uses that instead of hardcoding it. It's pretty simple, and I stole the idea from django-sslify: https://github.com/rdegges/django-sslify.

The basic idea is to rely on request.is_secure(), but I've added some extra smarts to deal with requests forwarded from a proxy too, which newer Djangos (>=1.4) deal with already, but older Djangos don't, since this is still used by mapumental on Django 1.3 from what I can see.

To use it, you don't need to add anything, but requests proxied won't be correctly identified unless you set SECURE_PROXY_SSL_HEADER as per: https://docs.djangoproject.com/en/1.4/ref/settings/#secure-proxy-ssl-header. Does this seem like a good idea?

stevenday avatar Jul 17 '13 12:07 stevenday