From 8411a8498075720d069284da12cc8e740cf3bf57 Mon Sep 17 00:00:00 2001 From: hjhan Date: Fri, 20 Mar 2026 14:07:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E6=B7=BB=E5=8A=A0SSO=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=85=8D=E7=BD=AE=E5=92=8C=E5=AF=86=E7=A0=81=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=A6=81=E7=94=A8=E5=8A=9F=E8=83=BD=20-=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=20skipSso=20=E5=8F=82=E6=95=B0=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=A4=A9=E9=A3=8E=E8=AF=81=E5=88=B8SSO=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=80=BB=E8=BE=91=20-=20=E6=B7=BB=E5=8A=A0=20ErpEleme?= =?UTF-8?q?nt.DisablePasswordLogin=20=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=AF=86=E7=A0=81=E7=99=BB=E5=BD=95=20-=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20SSO=E9=87=8D=E5=AE=9A=E5=90=91=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=BD=93=E5=AF=86=E7=A0=81=E7=99=BB=E5=BD=95=E8=A2=AB=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E6=97=B6=20-=20=E5=9C=A8appconfig.xml=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Erp.DisablePasswordLogin=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E6=95=B0=20-=20=E5=9C=A8AppUpgrader=E4=B8=AD?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96DisablePasswordLogin=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=95=B0=E6=8D=AE=20-=20=E6=89=A9=E5=B1=95IErpConfig?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0DisablePasswordLogin?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=AE=9A=E4=B9=89=20-=20=E5=9C=A8ProjectSett?= =?UTF-8?q?ings=E7=B1=BB=E4=B8=AD=E5=AE=9E=E7=8E=B0DisablePasswordLogin?= =?UTF-8?q?=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YLErp.Core/Configuration/Abstract/IErpConfig.cs | 7 ++++++- .../YLErp.Core/Configuration/ProjectSettings.cs | 2 ++ YLErpDAL/Modules/AppModule/AppUpgrader.cs | 4 +++- YLErpDAL/Resources/appconfig.xml | 2 ++ YLErpWeb/Controllers/AccountController.cs | 12 +++++++++++- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs b/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs index 1d6ec6c9..007e2eeb 100644 --- a/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs +++ b/Framework/YLErp.Core/Configuration/Abstract/IErpConfig.cs @@ -1,4 +1,4 @@ -using YLErp.Configuration.Enums; +using YLErp.Configuration.Enums; using static YLErp.DBModels.Consts.ConsReport; namespace YLErp.Configuration @@ -474,6 +474,11 @@ namespace YLErp.Configuration /// bool StrictAuthorize { get; } + /// + /// 禁用账号密码登录(仅允许SSO) + /// + bool DisablePasswordLogin { get; } + /// /// 风险对冲累积总盈亏是否统计已过期的场内交易 /// diff --git a/Framework/YLErp.Core/Configuration/ProjectSettings.cs b/Framework/YLErp.Core/Configuration/ProjectSettings.cs index c1b95b49..2aeaaffa 100644 --- a/Framework/YLErp.Core/Configuration/ProjectSettings.cs +++ b/Framework/YLErp.Core/Configuration/ProjectSettings.cs @@ -541,6 +541,8 @@ namespace YLErp /// public bool StrictAuthorize { get; set; } + public bool DisablePasswordLogin { get; set; } + /// /// 风险对冲累积总盈亏是否统计已过期的场内交易 /// diff --git a/YLErpDAL/Modules/AppModule/AppUpgrader.cs b/YLErpDAL/Modules/AppModule/AppUpgrader.cs index b6fea8ad..4a35b61f 100644 --- a/YLErpDAL/Modules/AppModule/AppUpgrader.cs +++ b/YLErpDAL/Modules/AppModule/AppUpgrader.cs @@ -1,4 +1,4 @@ -using System.Xml.Linq; +using System.Xml.Linq; namespace YLErp.Modules.AppModule { @@ -217,6 +217,8 @@ namespace YLErp.Modules.AppModule data = configService.RemoveData("ProjectConfig", "StrictAuthorize"); configService.AddDataIfNotExists("ProjectConfig", "Erp.StrictAuthorize", data?.PValue ?? "false", "bool", "严格的权限验证"); + configService.AddDataIfNotExists("ProjectConfig", "Erp.DisablePasswordLogin", "false", "bool", "禁用账号密码登录,仅允许SSO"); + configService.AddDataIfNotExists("ProjectConfig", "Erp.RiskAccPnl_SumExpiredExchangeTrades", data?.PValue ?? "false", "bool", "风险对冲累积总盈亏是否统计已过期的场内交易"); //----------------------------------------------- diff --git a/YLErpDAL/Resources/appconfig.xml b/YLErpDAL/Resources/appconfig.xml index d82f1af9..0633d249 100644 --- a/YLErpDAL/Resources/appconfig.xml +++ b/YLErpDAL/Resources/appconfig.xml @@ -52,5 +52,7 @@ + + diff --git a/YLErpWeb/Controllers/AccountController.cs b/YLErpWeb/Controllers/AccountController.cs index 74b3da42..9f83badb 100644 --- a/YLErpWeb/Controllers/AccountController.cs +++ b/YLErpWeb/Controllers/AccountController.cs @@ -44,11 +44,21 @@ namespace YLErp.Web.Controllers } } - if (!skipSso && SsoLoginConfig.SSO_Enable && PS.Config.Company == CompanyEnum.天风) + if (SsoLoginConfig.SSO_Enable && PS.Config.Company == CompanyEnum.天风) { return View("TianFengLogin"); } + if (PS.Config.ErpElement.DisablePasswordLogin) + { + var ssoUrl = YLErp.Web.Models.GeneralSSOConfig.AuthUrl; + if (!string.IsNullOrEmpty(ssoUrl)) + { + return Redirect(ssoUrl); + } + return Content("SSO登录未配置,请联系管理员"); + } + return LoginError(null); }