fix: 修改认证重定向地址 scheme 取值逻辑

pull/8762/head
Jiangjie.Bai 2 years ago committed by 老广
parent 7d0a19635a
commit 867ad94a30

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
import ipaddress import ipaddress
from urllib.parse import urljoin from urllib.parse import urljoin, urlparse
from django.conf import settings from django.conf import settings
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -39,7 +39,11 @@ def build_absolute_uri(request, path=None):
""" Build absolute redirect """ """ Build absolute redirect """
if path is None: if path is None:
path = '/' path = '/'
redirect_uri = request.build_absolute_uri(path) site_url = urlparse(settings.SITE_URL)
scheme = site_url.scheme or request.scheme
host = request.get_host()
url = f'{scheme}://{host}'
redirect_uri = urljoin(url, path)
return redirect_uri return redirect_uri
@ -50,6 +54,5 @@ def build_absolute_uri_for_oidc(request, path=None):
if settings.BASE_SITE_URL: if settings.BASE_SITE_URL:
# OIDC 专用配置项 # OIDC 专用配置项
redirect_uri = urljoin(settings.BASE_SITE_URL, path) redirect_uri = urljoin(settings.BASE_SITE_URL, path)
else: return redirect_uri
redirect_uri = request.build_absolute_uri(path) return build_absolute_uri(request, path=path)
return redirect_uri

Loading…
Cancel
Save