Web API重定向不工作



我正在尝试使用SAML和sp发起的SSO实现一个项目。我的项目是使用MS Web API。

以下是我的控制器中使用CompenentSpace作为SAML库启动SAML握手的代码:

   public IHttpActionResult SAMLInitiateRequestToIdp(string DistrictToken)
        {
            _idsRepository.SsoLogEntry( ServerAddress, "SAML/ADFS", null, null, null, 0, "Student", "Info Only", SAMLConfiguration.Current.PartnerIdentityProviderConfigurations + " "/* + Response.ToString()*/, null, null, null);
            string partnerIdP = "simon";
            try
            {
                MapDistrictClaim = false;
                DistrictClaim = DistrictToken;

                partnerIdP = _samlHelper.initiateRequestToSp(DistrictClaim, ServerAddress);
                SAMLServiceProvider.InitiateSSO(System.Web.HttpContext.Current.Response, null, partnerIdP);
                return Ok(new { data = "get ok" });

            }
            catch (Exception ex)
            {
                return Ok(new { data = "get ok" });
            }
        }

不要担心"catch"子句。我知道它没有任何作用。

我遇到的问题是,当我调用这个方法时,我得到以下响应:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://adfstest.mywebsite.com/adfs/ls/idpinitiatedsignon?SAMLRequest=AAAfZLLbtswEEV%2FReBe1tsPwjLgSDFqIG2FyOmim4IixzYBiVQ5lNsC%2BfhQctKmC2c7jzv3zMwaWdf2dDvYs3qEnwOg9fZlTn6INFs0i0Xjz8MF%2BGlzjPxlkzB%2FnsJKLJciTpuIeN%2FAoNQqJ%2FEsJN4ecYC9QsuUdaEwyvxw5UfJIU5oGNM4ma3C5DvxSjdFKmanzrO1PdIgYOKI1iVmnBkAw80gUarTjOtuygUtBlL0UkkrmQWB8qS0It5OGw6T%2F5wcWYsw%2BqgYorzA30hltNVct3dSCSeak8EoqhlKpIp1gNRyWm8%2FP1DHQZtrEdJPh0PlV1%2FrA%2FG2iGBGw4VWOHRgajAXyeHp8eEfAqK%2BRXCJg1H%2Flszk8CIFmC%2FOTk6ieRY%2Fh2mYbLO0cDsvMz8tw3t%2FWawiv5jv7nb3izTLVvFzzZRXSjhp70nJowTh1fysdeuCaI3klni%2Fu1YhnQ79MXj%2FuiWyWY%2FVdLqnedf%2FcTt7gyObsazgtWt5BXzD24t%2BHbwTv07q6Yi9LyvdSv5nPGnH7O1h0SyaIlL4x6mUDgp74BO%2Fu1Xb6l%2BFAfclObFmcNsNNtep%2F3%2F65gU%3D&amp;SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&amp;Signature=Dv9lr04SrKwRPxKs%2FLpqAqDsWPMcS%2BIFy%2FsLLWcAivf8s6WiV4dvei5LBa4MnYy4hXAyVYJ0JM7L6pBXaPCdz%2Fb5UtF525%2FQi%2Bpv8alyaplWJbXfgXWvjuRY%2FTxpnNN0wVGk7f6ZkCAmDEeZcSNNwW2YJGBvTk5kUORvQq1VhsMhZZmf3Q0VDRdjrTSzQ9K%2BbVEptm9Ed86Jb5I%2BYutc1U43FvSIQTNkpm8phC%2F3BlfyhbDRdMn3sSmCNkyel86oXfl7pnnozpDqPFWc6SRWaWJ%2BMv1IWs2SzcHbfvRAnkTdxx3Gokp%2Fd74f77oJLkUYNKgqsFIhrc6qSNqjO29heA%3D%3D">here</a>.</h2>
</body></html>
{"data":"get ok"}

当我给组件空间发邮件讨论我最初的问题时,我得到的回复是:"当你调用SAMLServiceProvider。InitiateSSO您正在使用HTTP-Redirect绑定发送SAML认证请求。

这意味着将302重定向返回给浏览器。例如:

然后浏览器应该对这个包含编码的SAMLRequest的URL执行GET。"

是否有一个原因,我得到这个响应,而不是浏览器重定向?

当我应该返回带有适当URL的重定向时,我返回了OK:

SAMLServiceProvider.InitiateSSO(System.Web.HttpContext.Current.Response, null, partnerIdP);
return Redirect(System.Web.HttpContext.Current.Response.RedirectLocation);

相关内容

  • 没有找到相关文章

最新更新