Added help text in local.settings.example

how to setup Horizon to use SSL-offloading proxy
to properly handle page redirects to SSL.

The example is for Django 1.4 only.
As I see at the moment Django 1.3 is
not supported (pip-requires says Django>=1.4),
so no example for Django 1.3 is added.

Fixes bug 999960

Change-Id: I3b885e84ef8332bfd0fe35a2307eb691cf34be03
This commit is contained in:
Tihomir Trifonov 2012-05-28 13:19:54 +03:00
parent 228c717e2a
commit 3b41cb97c4
2 changed files with 32 additions and 1 deletions

View File

@ -308,3 +308,28 @@ class HorizonTests(BaseHorizonTests):
follow=False,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(resp.status_code, 200)
def test_ssl_redirect_by_proxy(self):
users.get_user_from_request = self._real_get_user_from_request
dogs = horizon.get_dashboard("dogs")
puppies = dogs.get_panel("puppies")
url = puppies.get_absolute_url()
redirect_url = "?".join([urlresolvers.reverse("horizon:auth_login"),
"next=%s" % url])
client = Client()
client.logout()
resp = client.get(url)
self.assertRedirectsNoFollow(resp, redirect_url)
# Set SSL settings for test server
settings.TESTSERVER = 'https://testserver:80'
settings.SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL',
'https')
resp = client.get(url, HTTP_X_FORWARDED_PROTOCOL="https")
self.assertRedirectsNoFollow(resp, redirect_url)
# Restore settings
settings.TESTSERVER = 'http://testserver'
settings.SECURE_PROXY_SSL_HEADER = None

View File

@ -5,7 +5,13 @@ from django.utils.translation import ugettext_lazy as _
DEBUG = True
TEMPLATE_DEBUG = DEBUG
PROD = False
USE_SSL = False
# Set SSL proxy settings:
# For Django 1.4+ pass this header from the proxy after terminating the SSL,
# and don't forget to strip it from the client's request.
# For more information see:
# https://docs.djangoproject.com/en/1.4/ref/settings/#secure-proxy-ssl-header
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
# Note: You should change this value
SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'