【发布时间】:2019-08-05 16:15:48
【问题描述】:
在 SSO 实现中,验证用户后,我创建了一个 SAMLResponse 对象并使用 IdentityProvider.SendSAMLResponseByHTTPPost() 方法将其发布到默认登陆 URL。
IdentityProvider.SendSAMLResponseByHTTPPost(Response, strAssertionConsumerServiceURL, samlResponseXml, relayState);
samlResponseXml - 包含 SAML 请求 XML
在 ServiceProvider.ReceiveSAMLResponseByHTTPPost() 方法上,我收到以下 Catch 异常。
未能通过 HTTP post 接收 SAML 响应
身份提供者和服务提供者都在同一个网络域中。
附加了 ComponentSpace.SAML2 的日志
ComponentSpace.SAML2 Verbose: 0 : 9:19:44 PM: Missing form variable SAMLResponse
ComponentSpace.SAML2 Verbose: 0 : 9:19:44 PM: Exception: ComponentSpace.SAML2.SAMLBindingException: The form is missing the variable SAMLResponse
ComponentSpace.SAML2 Verbose: 0 : 9:19:44 PM: Exception: ComponentSpace.SAML2.SAMLBindingException: Failed to receive response over HTTP POST. ---> ComponentSpace.SAML2.SAMLBindingException: The form is missing the variable SAMLResponse
at ComponentSpace.SAML2.Bindings.HTTPPostBinding.GetFormVariables(HttpRequest httpRequest, String messageFormVariableName, XmlElement& samlMessage, String& relayState)
at ComponentSpace.SAML2.Bindings.HTTPPostBinding.ReceiveResponse(HttpRequest httpRequest, XmlElement& samlMessage, String& relayState)
--- End of inner exception stack trace ---
【问题讨论】:
-
您在表单中缺少 SAML,请查看错误。表单缺少变量 SAMLResponse。表单应包含一个名为 SAMLRepsponse 的隐藏字段并作为帖子发布
-
如果您使用浏览器开发工具或 Fiddler 来捕获 HTTP 流量,您应该能够看到导致此错误的原因。最可能的原因是正在接收 HTTP Get。 SAML 响应应在带有 SAMLResponse 发布数据的 HTTP 发布中发送。
-
在我的断言页面中,在通过以下方法使用 SAMLResponse 时,
ServiceProvider.ReceiveSAMLResponseByHTTPPost(Request, out samlResponseXml, out relayState);我收到错误“无法通过 HTTP post 接收 SAML 响应”@ComponentSpace 但是,根据代码,它是 POST动词,但 System.Web.HttpRequest 的 Request 对象 上的 Shift+F9 被标识为 GET。而且,这不能改变。如果是这样,仍然如何尝试 POST 呢? -
您需要确定收到 HTTP Get 的原因。最好的方法是捕获网络流量。身份提供者应该在 HTTP Post 中发送 SAML 响应。没有在 HTTP Get 中接收 SAML 响应的选项。 HTTP Get 可能源自您的应用程序或某个中间节点,而不是身份提供者。跟踪 HTTP 流量将有助于识别来源。
-
@ComponentSpace - 将 AssertionConsumer URL 指定为 strAssertionConsumerServiceURL = "localhost:58986/AssertionInternal"; POST Http VERB 被调用。能够接收 SAML 响应。谢谢..!!
标签: c# single-sign-on saml