【问题标题】:Thinktecture Identity Server Cors supportThinktecture Identity Server Cors 支持
【发布时间】:2013-12-13 00:26:10
【问题描述】:

我目前陷入这样一种情况,即我创建了一个 ASP Web API 项目并与我的主 MVC 应用程序分开部署,该应用程序使用 Thinktecture 身份服务器进行联合身份验证。

我面临的问题与 web api cors 支持有关。更具体地说,我在 mvc 应用程序中对自己进行身份验证,但是当它向 web api 发送请求时,我收到以下错误:

XMLHttpRequest cannot load XXX. The request was redirected to 'https://localhost/idsrv/issue/wsfed?wa=wsignin1.0&wtrealm=http%3a%2f%2floca…assive%2..., which is disallowed for cross-origin requests that require preflight. 

该错误是有道理的,因为该请求不包含 WSFederationAuthenticatioModule 验证我是否已登录所需的 Http 标头。

是否有任何我不知道的可能解决方法?

【问题讨论】:

    标签: asp.net-web-api cors claims-based-identity thinktecture-ident-server


    【解决方案1】:

    据我所知,您在这里有 3 个问题: 1. 如何通过 Web API 开启 WIF 认证。

    为此,您应该使用作为 NuGet 包存在的 Thinktecture.IdentityModel.45(或 MVC 5 - Thinktecture.IdentityModel)。在此处查看示例:Web Api security sample

    1. 之后,您必须在 Ajax 请求的安全标头中发送令牌。
    2. 如果您的 MVC 站点和 Web Api 不在同一个域中,那么您将不得不处理 CORS 问题

    关于问题 2 和 3,请参阅:Dog fooding our api authentication

    This 还应该让您了解如何使用在您的 MVC 站点中收到的安全令牌来通过您的 Web API 进行身份验证。

    【讨论】:

      猜你喜欢
      • 2015-05-29
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 2015-04-08
      • 1970-01-01
      • 2015-02-12
      • 2016-07-17
      • 2014-06-07
      相关资源
      最近更新 更多