diff --git a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs index 197e5fc7..5ef4b84d 100644 --- a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs @@ -3,6 +3,7 @@ using Bootstrap.DataAccess; using Longbow.GiteeAuth; using Longbow.GitHubAuth; using Longbow.Web; +using Longbow.WeChatAuth; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; @@ -199,5 +200,16 @@ namespace Bootstrap.Admin.Controllers var enabled = config.GetValue($"{nameof(GitHubOptions)}:Enabled", false); return Challenge(enabled ? GitHubDefaults.AuthenticationScheme : CookieAuthenticationDefaults.AuthenticationScheme); } + + /// + /// WeChat 认证 + /// + /// + [HttpGet] + public IActionResult WeChat([FromServices]IConfiguration config) + { + var enabled = config.GetValue($"{nameof(GitHubOptions)}:Enabled", false); + return Challenge(enabled ? WeChatDefaults.AuthenticationScheme : CookieAuthenticationDefaults.AuthenticationScheme); + } } } diff --git a/src/admin/Bootstrap.Admin/Startup.cs b/src/admin/Bootstrap.Admin/Startup.cs index ce3f2689..095bfef3 100644 --- a/src/admin/Bootstrap.Admin/Startup.cs +++ b/src/admin/Bootstrap.Admin/Startup.cs @@ -60,7 +60,7 @@ namespace Bootstrap.Admin services.AddSignalR().AddJsonProtocalDefault(); services.AddSignalRExceptionFilterHandler((client, ex) => client.SendMessageBody(ex).ConfigureAwait(false)); services.AddResponseCompression(); - services.AddBootstrapAdminAuthentication().AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure); + services.AddBootstrapAdminAuthentication().AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure).AddWeChat(OAuthHelper.Configure); services.AddSwagger(); services.AddButtonAuthorization(MenuHelper.AuthorizateButtons); services.AddBootstrapAdminBackgroundTask(); diff --git a/src/admin/Bootstrap.Admin/Views/Account/Login.cshtml b/src/admin/Bootstrap.Admin/Views/Account/Login.cshtml index 7f3658ce..225df077 100644 --- a/src/admin/Bootstrap.Admin/Views/Account/Login.cshtml +++ b/src/admin/Bootstrap.Admin/Views/Account/Login.cshtml @@ -122,8 +122,8 @@
- - + +
diff --git a/src/admin/Bootstrap.Admin/appsettings.Development.json b/src/admin/Bootstrap.Admin/appsettings.Development.json index 268521a3..db12e2cc 100644 --- a/src/admin/Bootstrap.Admin/appsettings.Development.json +++ b/src/admin/Bootstrap.Admin/appsettings.Development.json @@ -82,6 +82,16 @@ "App": "0", "StarredUrl": "https://api.github.com/user/starred/ArgoZhang/BootstrapAdmin" }, + "WeChatOptions": { + "Enabled": true, + "ClientId": "wxe2944ebb9e66551c", + "ClientSecret": "a4e36ddb18af218818e44bb7b8744fe6", + "CallbackPath": "/signin-weixin", + "HomePath": "/Admin/Profiles", + "Scope": [ "snsapi_login" ], + "Roles": [ "Administrators" ], + "App": "0" + }, "SMSOptions": { "CompanyCode": "", "MD5Key": "MD5Key", diff --git a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index a19f85b2..a5b9b2ad 100644 --- a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -7,13 +7,14 @@ - + +