Files
edx-platform/common/djangoapps/util/request.py
Chris Dodge a3211a7405 Introduction of the Microsite feature which allows for limited multi-tenant branding on a subdomain basis, e.g. foo.edx.org and bar.edx.org
fix errorenous logic when running a microsite that could reside in a hosting environment with a marketing site in front of it

pep8/pylint fixes

address PR feedback, remove underscore from test hostname

more pep8/pylint cleanup. Skip test_microsites test, it works on localdev, not on Jenkins. Need to talk with QA team

manually add Ned's single-to-double quote fix

change aws.py runtimes so that the microsite_dir that is read from configuration is changed to a python path

Conflicts:
	lms/templates/help_modal.html
2014-01-14 14:36:01 -05:00

19 lines
717 B
Python

""" Utility functions related to HTTP requests """
from django.conf import settings
from microsite_configuration.middleware import MicrositeConfiguration
def safe_get_host(request):
"""
Get the host name for this request, as safely as possible.
If ALLOWED_HOSTS is properly set, this calls request.get_host;
otherwise, this returns whatever settings.SITE_NAME is set to.
This ensures we will never accept an untrusted value of get_host()
"""
if isinstance(settings.ALLOWED_HOSTS, (list, tuple)) and '*' not in settings.ALLOWED_HOSTS:
return request.get_host()
else:
return MicrositeConfiguration.get_microsite_configuration_value('site_domain', settings.SITE_NAME)