【发布时间】:2017-08-28 07:48:42
【问题描述】:
在将 ASPNetCore 1.1 项目迁移到 ASPNetCore 2.0 期间,我们偶然发现了 Cookie-AuthN 及其SessionStore 的问题。
ASP.NET Core 1 允许我们做这样的事情:
public void ConfigureServices(...) {
Services.AddDistributedSqlServerCache(...);
Services.AddSingleton<DistributedCookieSessionStore>(); /// SQL based store
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) {
var cookieOptions = app.ApplicationServices.GetRequiredService<IOptions<CookieAuthenticationOptions>>().Value;
cookieOptions.SessionStore = app.ApplicationServices.GetRequiredService<DistributedCookieSessionStore>();
app.UseCookieAuthentication(cookieOptions);
}
杂乱无章,但尽其所能。
现在使用 ASP.NET Core 2 app.UseAuthentication() 没有允许修改选项的签名,并且我无法使用 DI 来获取会话存储。
【问题讨论】:
标签: asp.net-core-2.0