【发布时间】:2014-09-29 13:25:46
【问题描述】:
我正在开发一个 mvc 5 Web 应用程序,其身份验证由 owin 和表单身份验证实现。
它与它提供的开箱即用的声明配合得很好。 现在我正在尝试使用 Windows 身份验证来登录系统
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context and user manager to use a single instance per request
// app.CreatePerOwinContext(ApplicationDbContext.Create);
// app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Uncomment the following lines to enable logging in with third party login providers
//app.UseMicrosoftAccountAuthentication(
// clientId: "",
// clientSecret: "");
//app.UseTwitterAuthentication(
// consumerKey: "",
// consumerSecret: "");
//app.UseFacebookAuthentication(
// appId: "",
// appSecret: "");
//// app.UseGoogleAuthentication(
// clientId: "000-000.apps.googleusercontent.com",
// clientSecret: "00000000000");
}
我已经评论了所有的提供者。
我正在尝试在登录过程中推送声明,但用户 (window.identity.principal) 已通过身份验证,我可以通过 authenticationmanger.current.user.Isauthenticated 进行检查。
我正在尝试登录,但未推送声明,但即使未触发签名命令,我也可以看到用户声明中存在声明列表。 就像 Windows 身份验证中的 owin 已经知道谁是当前用户及其名称和声明。但是我希望将一些自定义的一次性声明推送到我无法实现的现有列表中。
所有现有的声明都是类型系统声明,这让我怀疑我是否可以修改声明。
如何修改或更新或扩展现有的索赔列表?
我尝试了声明的撤销方法,它适用于表单身份验证。
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 authentication owin