Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sniff the scheme in FullyQualifiedRedirectMiddleware rather than hardcoding it to http #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

stevenday
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant