MVC客户端无法在IIS上进行身份验证

问题描述:

我已经成功使用IdentityServer3实现。我创建ASP.NET MVC5客户端隐含的流动,这Owin启动配置:MVC客户端无法在IIS上进行身份验证

app.UseCookieAuthentication(new CookieAuthenticationOptions 
    { AuthenticationType = "Cookies" }); 

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
    { 
     ClientId = "mvc.client", 
     Authority = Constants.ServerUri, 
     RedirectUri = Constants.MvcClientUri, 
     ResponseType = "id_token", 
     Scope = "openid profile", 
     UseTokenLifetime = false, 
     SignInAsAuthenticationType = "Cookies", 

     Notifications = new OpenIdConnectAuthenticationNotifications 
     { SecurityTokenValidated = TokenValidatedNotification }, 
     }); 

一切都运行完美运行在本地IIS Express,但在部署到生产IIS服务器失败。在这两种情况下身份验证都成功 - id_token从相同的IdentityServer返回,但生产用户永远不会通过身份验证,通知不会被触发。项目引用Microsoft.Owin.Host.SystemWeb程序集。我已经注册异常处理OwinMiddleware作为第一个,但没有未处理的异常被捕获。

+0

你有没有尝试过AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie? –

+0

我试过但没有变化 - 在当地工作,未在生产中验证 –

请确保生产IIS的网站配置为使用Anonymous身份验证,因为您不依赖于IIS的身份验证基础结构,所以您希望请求通过IIS进行流动并到达负责身份验证的OWIN中间件。

+0

只允许使用“匿名”。 _IIS的身份验证基础结构_是什么意思? –

+0

IIS有它自己的身份验证机制,但是当您使用OWIN并在应用程序级别验证用户(使用“中间件”)时,您希望IIS跳过验证处理。如果你说IIS已经配置了只有'匿名'选项,那么问题不在那里。 –