当前位置: 首页 > 知识库问答 >
问题:

未能通过 HTTP 发布接收 SAML 响应

曾永新
2023-03-14

在SSO实现中,在验证用户后,我创建了一个SAMLResponse对象,并使用IdentityProvider将其发布到默认登录URL。sendSamlResponseByHttpSt()方法。

身份提供程序。SendSamlResponseByHttpost(响应,strAssertionConsumerServiceURL,SamlRespossExml,relayState);

SAML请求XML-包含SAML请求XML

在ServiceProvider上。ReceiveSAMLResponseByHTTPPost()方法,我得到了下面的Catch异常。

未能通过 HTTP 发布接收 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 ---

共有2个答案

杜鸿彩
2023-03-14

在使用Firebug Console和Fiddler2进行多次尝试后,已经确定当我尝试将数据发布到AssersisConsumerServiceURL页面时,即使使用了SendSAMLResponseByHTTPPost()和 ReceiveSAMLResponseByHTTPPost()也是如此。

 string strAssertionConsumerServiceURL = "http://localhost:58986/AssertionInternal.aspx";

上述断言消费者服务网址被修改如下,

 string strAssertionConsumerServiceURL = "http://localhost:58986/AssertionInternal";

通过此URL,SAML POST数据已成功接收。

使用.aspx扩展名指定 URL 在我的应用程序中调用了 GET 谓词,而不是 POST 谓词。

孙风畔
2023-03-14

问题:
(1)无法通过HTTP帖子接收SAML响应

(2)

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

分辨率:< br >

SAML异常日志表明SAML响应的形式/格式不正确。

为SSO创建SAML响应提供了以下示例代码来演示如何使用ComponentSpace库生成SAML响应。

        // Create a SAML response with the user's local identity.
        private SAMLResponse CreateSAMLResponse()
        {
            //Trace.Write("IdPreating SAML response");
           SAMLResponse samlResponse = new SAMLResponse();
            samlResponse.Destination = strAssertionConsumerServiceURL;
            Issuer issuer = new Issuer(CreateAbsoluteURL("~/"));
            samlResponse.Issuer = issuer;
            samlResponse.Status = new Status(SAMLIdentifiers.PrimaryStatusCodes.Success, null);
            SAMLAssertion samlAssertion = new SAMLAssertion();
            samlAssertion.Issuer = issuer;
            //Subject subject = new Subject(new NameID(User.Identity.Name));
            Subject subject = new Subject(new NameID());
            SubjectConfirmation subjectConfirmation = new SubjectConfirmation(SAMLIdentifiers.SubjectConfirmationMethods.Bearer);
            SubjectConfirmationData subjectConfirmationData = new SubjectConfirmationData();
            subjectConfirmationData.Recipient = strAssertionConsumerServiceURL;
            subjectConfirmation.SubjectConfirmationData = subjectConfirmationData;
            subject.SubjectConfirmations.Add(subjectConfirmation);
            samlAssertion.Subject = subject;
            samlAssertion.SetAttributeValue("MemberId", this.txtMemberId.Text);
            samlAssertion.SetAttributeValue("Name", this.txtName.Text);
            samlAssertion.SetAttributeValue("Phone", this.txtPhone.Text);
            AuthnStatement authnStatement = new AuthnStatement();
            authnStatement.AuthnContext = new AuthnContext();
            authnStatement.AuthnContext.AuthnContextClassRef = new AuthnContextClassRef(SAMLIdentifiers.AuthnContextClasses.Password);
            samlAssertion.Statements.Add(authnStatement);
           samlResponse.Assertions.Add(samlAssertion);
            return samlResponse;
        }
        // Send the SAML response to the SP.
        private void SendSAMLResponse(SAMLResponse samlResponse, string relayState)
        {
            // Serialize the SAML response for transmission.
            XmlElement samlResponseXml = samlResponse.ToXml();
            // Sign the SAML response.
           X509Certificate2 x509Certificate = (X509Certificate2)Application["IdPX509Certificate"];
            SAMLMessageSignature.Generate(samlResponseXml, x509Certificate.PrivateKey, x509Certificate);
          IdentityProvider.SendSAMLResponseByHTTPPost(Response, strAssertionConsumerServiceURL, samlResponseXml, relayState);
        }
 类似资料:
  • 问题内容: 第8.1.2.2节流水线说: “服务器必须以接收请求的相同顺序发送对请求的响应”。 因此,我想,如果我从浏览器发出多个AJAX请求,它们仍将按照服务器接收到的顺序进行处理。 但是后来,我从Alex Maccaw 读了这篇文章,他说: “最后一个问题是并行发送的Ajax请求。如果用户创建一条记录,然后立即更新同一条记录,则将同时发送两个Ajax请求,即POST和PUT。但是,如果服务器在

  • 我有一个。Net Core 5控制台应用程序在Orange Pi上的Linux(Debian 10)上运行。我正在尝试将一些JSON发布到Web API(也写在. Net Core 5中并托管在Azure应用服务上)API有两个HTTPPOSTendpoint-一个用于接收单个对象,另一个几乎相同的endpoint用于接收所述对象的数组。 当我将单个对象发布到第一个endpoint时,我会收到20

  • 我是一个新手。我试图通过反向工程请求和刮取数据来获取flipkart卖家的产品数据。我尝试的URL是:https://www.flipkart.com/sellers?pid=hsaffjwt2wuyhhhx,其中包含特定产品的销售商列表。 当我在Google chrome中打开network选项卡时,我可以看到它向https://www.flipkart.com/api/3/page/dynam

  • 问题内容: 我在javascript中创建了一个函数,像这样: 我调用了脚本文件,并将其用于方法。 在控制器中,我有此操作 但是随着方法参数变为空。 该模型: 用POST发送数据时,我该如何采取行动方法? 我不知道该怎么用。另外,可以通过JSON将响应发送回(到ajax)吗? 问题答案: 建立模型 像下面的控制器 Java脚本

  • 这是我第一次尝试进行基本身份验证,但似乎没有任何效果。Axios post未发送数据/控制器未返回响应。我找不到我到底哪里出错了,但我想知道我的http post请求的主体是否必须与requestbody匹配,或者我需要做什么更改才能让UserRepository将表单dat保存在数据库中? }

  • 我有两个web应用程序,它们在AWS EC2实例的docker容器中的单个Tomcat上运行。一个web应用程序是100%角度静态内容,另一个是REST应用程序。当我在笔记本电脑上运行web应用程序时,一切都正常运行。当我在EC2实例上运行docker容器并直接使用公共IP访问web应用程序时,一切都正常运行。然而,当我试图通过ELB访问web应用程序时,对静态内容的请求得到了很好的处理,但对RE