diff --git a/.gitignore b/.gitignore index ca88a977..d9ddf09a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -## Ignore Visual Studio temporary files, build results, and +## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files @@ -223,5 +223,6 @@ logfile /YLWebAPI/appsettings.Development.json /YLManageAPI/appsettings.Development.json /YLWebAPI/App_Docs +/.idea /.idea/.idea.YLerpbase/.idea /NuGet.Config diff --git a/YLErpWeb/App/Startup.cs b/YLErpWeb/App/Startup.cs index 2d8b451d..33b5b450 100644 --- a/YLErpWeb/App/Startup.cs +++ b/YLErpWeb/App/Startup.cs @@ -70,7 +70,7 @@ namespace YLErp.Web } SsoLoginConfig.Init(); - GeneralSSOConfig.Init(); + GeneralSSOConfig.Init(config); SetDefaultInitial(); } diff --git a/YLErpWeb/App_Data/Config/通用SSO.json b/YLErpWeb/App_Data/Config/通用SSO.json deleted file mode 100644 index db68642d..00000000 --- a/YLErpWeb/App_Data/Config/通用SSO.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "enable": true, //是否启用通用SSO登录 - "auth_url": "http://127.0.0.1:8888/sso/login", //SSO授权地址 - "callback_url": "http://localhost:49462/Account/Callback", //回调处理地址 - "get_user_url": "http://127.0.0.1:8888/sso/getSsoUser" //获取用户信息接口地址 -} diff --git a/YLErpWeb/Models/GeneralSSOConfig.cs b/YLErpWeb/Models/GeneralSSOConfig.cs index 9bd8a1d0..fe780142 100644 --- a/YLErpWeb/Models/GeneralSSOConfig.cs +++ b/YLErpWeb/Models/GeneralSSOConfig.cs @@ -1,3 +1,5 @@ +using Microsoft.Extensions.Configuration; + namespace YLErp.Web.Models { /// @@ -27,14 +29,24 @@ namespace YLErp.Web.Models /// public static string GetUserUrl => _config?.get_user_url; + /// + /// 初始化SSO配置 + /// + /// 配置对象 + public static void Init(IConfiguration config) + { + if (config != null) + { + _config = config.GetSection("GeneralSSO").Get(); + } + } + + /// + /// 初始化SSO配置(兼容旧方法) + /// public static void Init() { - var configFilePath = Server.MapPath("~/app_data/config/通用SSO.json"); - if (System.IO.File.Exists(configFilePath)) - { - var json = System.IO.File.ReadAllText(configFilePath); - _config = Newtonsoft.Json.JsonConvert.DeserializeObject(json); - } + // 保留旧方法以保持向后兼容 } class InnerConfig diff --git a/YLErpWeb/appsettings.dev.json b/YLErpWeb/appsettings.dev.json index 6d28cf55..760a2ea3 100644 --- a/YLErpWeb/appsettings.dev.json +++ b/YLErpWeb/appsettings.dev.json @@ -81,5 +81,11 @@ "ObjectClass": "ZSZQ_CWYSPJYQRSDZWF", //OA文件类别 "Urgent": 1, //紧急程度,1一般 2紧急 3加急 "Issend": 0 //流程是否自动发送,0不发送,1自动发送下一步 + }, + "GeneralSSO": { + "enable": true, //是否启用通用SSO登录 + "auth_url": "http://127.0.0.1:8888/sso/login", //SSO授权地址 + "callback_url": "http://localhost:49462/Account/Callback", //回调处理地址 + "get_user_url": "http://127.0.0.1:8888/sso/getSsoUser" //获取用户信息接口地址 } } \ No newline at end of file