Python django.conf.settings 模块,SECURE_PROXY_SSL_HEADER 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用django.conf.settings.SECURE_PROXY_SSL_HEADER

项目:mos-horizon    作者:Mirantis    | 项目源码 | 文件源码
def test_ssl_redirect_by_proxy(self):
        dogs = horizon.get_dashboard("dogs")
        puppies = dogs.get_panel("puppies")
        url = puppies.get_absolute_url()
        redirect_url = "?".join([settings.LOGIN_URL,
                                 "next=%s" % url])

        self.client.logout()
        resp = self.client.get(url)
        if django.VERSION >= (1, 9):
            self.assertRedirects(resp, settings.TESTSERVER + redirect_url)
        else:
            self.assertRedirects(resp, redirect_url)

        # Set SSL settings for test server
        settings.SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL',
                                            'https')

        resp = self.client.get(url, HTTP_X_FORWARDED_PROTOCOL="https")
        self.assertEqual(302, resp.status_code)
        self.assertEqual('https://testserver:80%s' % redirect_url,
                         resp['location'])

        # Restore settings
        settings.SECURE_PROXY_SSL_HEADER = None
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def scheme(self):
        # First, check the SECURE_PROXY_SSL_HEADER setting.
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header, None) == value:
                return 'https'
        # Failing that, fall back to _get_scheme(), which is a hook for
        # subclasses to implement.
        return self._get_scheme()
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def scheme(self):
        # First, check the SECURE_PROXY_SSL_HEADER setting.
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header, None) == value:
                return 'https'
        # Failing that, fall back to _get_scheme(), which is a hook for
        # subclasses to implement.
        return self._get_scheme()
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def scheme(self):
        # First, check the SECURE_PROXY_SSL_HEADER setting.
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header, None) == value:
                return 'https'
        # Failing that, fall back to _get_scheme(), which is a hook for
        # subclasses to implement.
        return self._get_scheme()
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:liberator    作者:libscie    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:django-httpxforwardedfor    作者:PaesslerAG    | 项目源码 | 文件源码
def test_x_forwarded_proto_does_nothing_if_wrong_protocol(self):
        self.assertEqual(
            settings.SECURE_PROXY_SSL_HEADER,
            ('HTTP_X_FORWARDED_PROTO', 'https'))
        request = self.create_request(HTTP_X_FORWARDED_PROTO="ftp")
        self.assertFalse(request.is_secure())
        request = self.create_request(HTTP_X_FORWARDED_PROTO="http")
        self.assertFalse(request.is_secure())
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def scheme(self):
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header) == value:
                return 'https'
        return self._get_scheme()
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def scheme(self):
        # First, check the SECURE_PROXY_SSL_HEADER setting.
        if settings.SECURE_PROXY_SSL_HEADER:
            try:
                header, value = settings.SECURE_PROXY_SSL_HEADER
            except ValueError:
                raise ImproperlyConfigured(
                    'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
                )
            if self.META.get(header, None) == value:
                return 'https'
        # Failing that, fall back to _get_scheme(), which is a hook for
        # subclasses to implement.
        return self._get_scheme()