我正在使用Asp.net Identity(OWIN)构建ASP.NET MVC 5网站,并希望支持传统的用户名/密码身份验证以及针对Azure Active Directory的身份验证.此应用程序不需要针对Microsoft ID(Live ID),Facebook,Twitter或任何其他外部提供程序进行身份验证.我找到的最接近的SO问题是:如何在ASP.NET MVC上执行Azure Active Directory单点登录和表单身份验证
我查看了使用"个人用户帐户"选项以及VS 2015中的"工作和学校帐户"选项创建项目时创建的示例.我的身份验证工作正常; 只有当我尝试将它们结合起来时,我才遇到问题.
在我的Startup_Auth.cs文件中,我正在配置OWIN,如下所示:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
//app.UseCookieAuthentication(new CookieAuthenticationOptions { });
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
LoginPath = new PathString("/account/sign-in")
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
{
ValidateIssuer = false,
},
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = (context) =>
{
return Task.FromResult(0);
},
AuthorizationCodeReceived = (context) =>
{
return Task.FromResult(0);
},
AuthenticationFailed = (context) …
Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc azure asp.net-identity azure-active-directory