是否可以在同一个应用程序中使用Thinktecture的IdentityModel和System.IdentityModel SessionAuthenticationModule cookie?

时间:2014-01-31 13:45:52

标签: asp.net-web-api wif thinktecture-ident-model

我有一个网络应用程序,其中包含浏览器提供的JavaScript应用程序和Android手机应用程序使用的服务。

javascript应用程序使用System.IdentityModel.SessionAuthenticationModule cookie进行身份验证,移动应用程序在Authentication头中使用JWT令牌。

我可以配置应用程序以使用System.IdentityModel.SessionAuthenticationModule和cookie工作或thinktecture AuthorizationHandler和令牌工作,但我无法弄清楚如何让它们同时工作?

这个答案Thinktecture IdentityModel AuthenticationConfiguration Mapping for Cookie - how?表明它不可能,但似乎是使用自定义Cookie,而不是FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(token);

1 个答案:

答案 0 :(得分:0)

只要web.config中没有授权元素阻碍,这应该可以正常工作。或者IOW使用AuthorizeAttribute。

但这是基于cookie的Web API身份验证的一般问题,因为现在您正在开放自己的CSRF攻击。您真正应该做的是分离UI和API,并将这两个客户端视为基于令牌的身份验证的“外部”。但这当然是一个重大的架构变化(虽然方向正确)。

相关问题