Signed-off-by: 南通一次元科技有限公司 <guwangtu@icimeta.com>
This commit is contained in:
1 parent
b91954df4a
commit
4b5b119c18
23 files changed
+526
-53
No files matched your search
@@ -33,6 +33,7 @@ FAIL_WINDOW_SECONDS = 600
|
||||
|
||||
# 门户登录地址(默认按访问的 Host 推导,指向 8080 端口)
|
||||
PORTAL_LOGIN_URL = os.getenv("PORTAL_LOGIN_URL", "")
|
||||
PUBLIC_DOMAIN = os.getenv("PUBLIC_DOMAIN", "").strip().lower().lstrip(".")
|
||||
|
||||
ENABLED = bool(AUTH_USER and AUTH_PASSWORD and SESSION_SECRET)
|
||||
|
||||
@@ -441,9 +442,13 @@ def safe_next(next_url: str, request) -> str:
|
||||
return next_url
|
||||
try:
|
||||
parsed = urlparse(next_url)
|
||||
host = (request.headers.get("host") or "").split(":")[0]
|
||||
if parsed.scheme == "http" and parsed.hostname == host:
|
||||
return next_url
|
||||
host = (request.headers.get("host") or "").split(":")[0].lower()
|
||||
target = (parsed.hostname or "").lower()
|
||||
if parsed.scheme in ("http", "https"):
|
||||
if target == host:
|
||||
return next_url
|
||||
if PUBLIC_DOMAIN and (target == PUBLIC_DOMAIN or target.endswith("." + PUBLIC_DOMAIN)):
|
||||
return next_url
|
||||
except Exception:
|
||||
pass
|
||||
return "/"
|
||||
|
||||
Reference in new issue
Block a user