【发布时间】:2018-08-25 23:42:54
【问题描述】:
我在两个单独的 ASP.NET Core 项目中使用WsFederation。
每个项目在Startup.cs中都有以下内容
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
})
.AddWsFederation(options =>
{
options.Wtrealm = Configuration["Wtrealm"];
options.MetadataAddress = "http://example.com/metadata.xml";
options.SkipUnrecognizedRequests = true;
options.RequireHttpsMetadata = false;
options.UseTokenLifetime = false;
})
.AddCookie(options =>
{
options.Cookie.Name = "MySharedCookie";
options.Cookie.Path = "/";
options.Cookie.Domain = ".dev.example.com";
});
我在浏览器中加载项目 #1 并获得我的 cookie:
然后我导航到同一子域上的项目#2。但是,项目 #2 无法识别 MySharedCookie 并重新进行身份验证。我得到一个名称相同但值不同的新 cookie:
我在 ASP.NET Core 中尝试做的事情是否可行?在 ASP.NET Core 中有没有办法可以将项目 #1 的 cookie 与项目 #2 共享?
【问题讨论】:
-
也许this 可以帮忙?
-
他们还必须共享他们的数据保护密钥。
标签: c# asp.net-core asp.net-core-mvc asp.net-core-2.0