【问题标题】:Is it possible to use Thinktecture's IdentityModel and a System.IdentityModel SessionAuthenticationModule cookie in the same application?是否可以在同一个应用程序中使用 Thinktecture 的 IdentityModel 和 System.IdentityModel SessionAuthenticationModule cookie?
【发布时间】:2014-02-01 17:16:33
【问题描述】:

我有一个网络应用程序,其中包含浏览器提供的 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);

【问题讨论】:

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


    【解决方案1】:

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

    但是对于基于 cookie 的 Web API 身份验证来说,这是一个普遍的问题,因为现在您正在向 CSRF 攻击敞开大门。您真正应该做的是分离 UI 和 API,并将两个客户端视为“外部”,并使用基于令牌的身份验证。但这当然是一个巨大的架构变化(尽管方向正确)。

    【讨论】:

    • 是的,在我尝试修改导致 SessionAuthenticationManager 代码无法正常工作的 ClaimsAuthenticationManager 中的声明之前,一切正常。
    猜你喜欢
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    相关资源
    最近更新 更多