From 5139f9c4b9b39152b71ec602b315d18a1f37b93e Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Tue, 14 Dec 2021 17:13:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20saml2=E8=AE=A4=E8=AF=81=E6=94=AF?= =?UTF-8?q?=E6=8C=81https=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/saml2/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/authentication/backends/saml2/views.py b/apps/authentication/backends/saml2/views.py index 9841fcd1d..f1affb8af 100644 --- a/apps/authentication/backends/saml2/views.py +++ b/apps/authentication/backends/saml2/views.py @@ -1,5 +1,7 @@ import copy +from urllib import parse + from django.views import View from django.contrib import auth as auth from django.urls import reverse @@ -23,9 +25,13 @@ logger = get_logger(__file__) class PrepareRequestMixin: @staticmethod - def prepare_django_request(request): + def is_secure(): + url_result = parse.urlparse(settings.SITE_URL) + return 'on' if url_result.scheme == 'https' else 'off' + + def prepare_django_request(self, request): result = { - 'https': 'on' if request.is_secure() else 'off', + 'https': self.is_secure(), 'http_host': request.META['HTTP_HOST'], 'script_name': request.META['PATH_INFO'], 'get_data': request.GET.copy(),