【发布时间】:2015-10-09 11:56:39
【问题描述】:
VS 2013 SPA 模板配置了 cookie 中间件,以及 OAuth MW 或 ExternalCookie MW 等其他中间件。
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(20),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
由于 WebApi 将通过不记名令牌授权从客户端进行的调用,并且外部 cookie 中间件支持外部登录提供程序,因此 cookie 中间件在其中扮演什么角色?
【问题讨论】:
标签: visual-studio-2013 single-page-application katana owin-middleware