當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.SECURE_PROXY_SSL_HEADER屬性代碼示例

本文整理匯總了Python中django.conf.settings.SECURE_PROXY_SSL_HEADER屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.SECURE_PROXY_SSL_HEADER屬性的具體用法?Python settings.SECURE_PROXY_SSL_HEADER怎麽用?Python settings.SECURE_PROXY_SSL_HEADER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.SECURE_PROXY_SSL_HEADER屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ssl_redirect_by_proxy

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
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)
        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 
開發者ID:CiscoSystems,項目名稱:avos,代碼行數:24,代碼來源:base.py

示例2: scheme

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
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() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:16,代碼來源:request.py

示例3: scheme

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
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() 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:13,代碼來源:request.py

示例4: is_secure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
def is_secure(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 True

        # Failing that, fall back to _is_secure(), which is a hook for
        # subclasses to implement.
        return self._is_secure() 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:15,代碼來源:request.py

示例5: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
def handle(self, *args, **options):
        site = ApplyHomePage.objects.first().get_site()
        set_urlconf('hypha.apply.urls')

        # Mock a HTTPRequest in order to pass the site settings into the
        # templates
        request = HttpRequest()
        request.META['SERVER_NAME'] = site.hostname
        request.META['SERVER_PORT'] = site.port
        request.META[settings.SECURE_PROXY_SSL_HEADER] = 'https'
        request.session = {}
        request._messages = FallbackStorage(request)

        today = timezone.now().date()
        due_date = today + relativedelta(days=options['days_before'])
        for project in Project.objects.in_progress():
            next_report = project.report_config.current_due_report()
            due_soon = next_report.end_date == due_date
            not_notified_today = (
                not next_report.notified or
                next_report.notified.date() != today
            )
            if due_soon and not_notified_today:
                messenger(
                    MESSAGES.REPORT_NOTIFY,
                    request=request,
                    user=None,
                    source=project,
                    related=next_report,
                )
                # Notify about the due report
                next_report.notified = timezone.now()
                next_report.save()
                self.stdout.write(
                    self.style.SUCCESS(f'Notified project: {project.id}')
                ) 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:38,代碼來源:notify_report_due.py

示例6: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
def handle(self, *args, **options):
        site = ApplyHomePage.objects.first().get_site()
        set_urlconf('hypha.apply.urls')

        # Mock a HTTPRequest in order to pass the site settings into the
        # templates
        request = HttpRequest()
        request.META['SERVER_NAME'] = site.hostname
        request.META['SERVER_PORT'] = site.port
        request.META[settings.SECURE_PROXY_SSL_HEADER] = 'https'
        request.session = {}
        request._messages = FallbackStorage(request)

        for reminder in Reminder.objects.filter(sent=False, time__lte=timezone.now()):
            messenger(
                reminder.action_message,
                request=request,
                user=None,
                source=reminder.submission,
                related=reminder,
            )
            self.stdout.write(
                self.style.SUCCESS(f'Reminder sent: {reminder.id}')
            )
            reminder.sent = True
            reminder.save() 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:28,代碼來源:send_reminders.py

示例7: _get_dummy_headers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SECURE_PROXY_SSL_HEADER [as 別名]
def _get_dummy_headers(self, original_request=None):
        """
        Return a dict of META information to be included in a faked HttpRequest object to pass to
        serve_preview.
        """
        url = self._get_dummy_header_url(original_request)
        if url:
            url_info = urlparse(url)
            hostname = url_info.hostname
            path = url_info.path
            port = url_info.port or (443 if url_info.scheme == 'https' else 80)
            scheme = url_info.scheme
        else:
            # Cannot determine a URL to this page - cobble one together based on
            # whatever we find in ALLOWED_HOSTS
            try:
                hostname = settings.ALLOWED_HOSTS[0]
                if hostname == '*':
                    # '*' is a valid value to find in ALLOWED_HOSTS[0], but it's not a valid domain name.
                    # So we pretend it isn't there.
                    raise IndexError
            except IndexError:
                hostname = 'localhost'
            path = '/'
            port = 80
            scheme = 'http'

        http_host = hostname
        if port != (443 if scheme == 'https' else 80):
            http_host = '%s:%s' % (http_host, port)
        dummy_values = {
            'REQUEST_METHOD': 'GET',
            'PATH_INFO': path,
            'SERVER_NAME': hostname,
            'SERVER_PORT': port,
            'SERVER_PROTOCOL': 'HTTP/1.1',
            'HTTP_HOST': http_host,
            'wsgi.version': (1, 0),
            'wsgi.input': StringIO(),
            'wsgi.errors': StringIO(),
            'wsgi.url_scheme': scheme,
            'wsgi.multithread': True,
            'wsgi.multiprocess': True,
            'wsgi.run_once': False,
        }

        # Add important values from the original request object, if it was provided.
        HEADERS_FROM_ORIGINAL_REQUEST = [
            'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_COOKIE', 'HTTP_USER_AGENT', 'HTTP_AUTHORIZATION',
            'wsgi.version', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.run_once',
        ]
        if settings.SECURE_PROXY_SSL_HEADER:
            HEADERS_FROM_ORIGINAL_REQUEST.append(settings.SECURE_PROXY_SSL_HEADER[0])
        if original_request:
            for header in HEADERS_FROM_ORIGINAL_REQUEST:
                if header in original_request.META:
                    dummy_values[header] = original_request.META[header]

        return dummy_values 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:61,代碼來源:models.py


注:本文中的django.conf.settings.SECURE_PROXY_SSL_HEADER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。