From 8b3ffcee03ffcfc9346d1fe6b332a209eec346cd Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 28 Sep 2019 00:49:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(#I12T0Y):=20=E6=94=AF=E6=8C=81QQ=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E5=85=BC=E5=AE=B9=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #I12T0Y #Issue link https://gitee.com/LongbowEnterprise/dashboard/issues?id=I12T0Y --- src/admin/Bootstrap.Admin/Startup.cs | 10 +++++++++- src/admin/Bootstrap.Admin/appsettings.json | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/admin/Bootstrap.Admin/Startup.cs b/src/admin/Bootstrap.Admin/Startup.cs index d09d2d10..27953d84 100644 --- a/src/admin/Bootstrap.Admin/Startup.cs +++ b/src/admin/Bootstrap.Admin/Startup.cs @@ -1,6 +1,7 @@ using Bootstrap.DataAccess; using Longbow.Web; using Longbow.Web.SignalR; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -60,7 +61,8 @@ 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); + // 兼容 QQ 浏览器兼容模式 + services.AddBootstrapAdminAuthentication(configureCookies: ConfigureCookie).AddGitee(OAuthHelper.Configure).AddGitHub(OAuthHelper.Configure); services.AddSwagger(); services.AddButtonAuthorization(MenuHelper.AuthorizateButtons); services.AddBootstrapAdminBackgroundTask(); @@ -122,5 +124,11 @@ namespace Bootstrap.Admin app.UseSwagger(Configuration["SwaggerPathBase"].TrimEnd('/')); app.UseMvcWithDefaultRoute(); } + + private void ConfigureCookie(CookieAuthenticationOptions options) + { + var supportQQ = Configuration.GetValue("SupportQQBrowser", false); + if (supportQQ) options.Cookie.SameSite = SameSiteMode.None; + } } } diff --git a/src/admin/Bootstrap.Admin/appsettings.json b/src/admin/Bootstrap.Admin/appsettings.json index 877e3667..ca1faca0 100644 --- a/src/admin/Bootstrap.Admin/appsettings.json +++ b/src/admin/Bootstrap.Admin/appsettings.json @@ -15,6 +15,7 @@ "ConnectionStrings": { "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" }, + "SupportQQBrowser": false, "DB": [ { "Enabled": false,