【问题标题】:How do you implement SAML for SSO with Influitive?您如何通过 Influitive 为 SSO 实施 SAML?
【发布时间】:2016-07-17 14:58:20
【问题描述】:

我正在尝试通过 SAML 为我的 Influitive 集线器实施 SSO。我遵循了他们的文档here 并按照他们的规范设置了我的环境。我有我的证书的指纹以及通过 QueryString 处理他们的 SAMLRequest 的端点。

我正在使用here 概述的 Web 浏览器 SSO 用例。

为了形成我的 SAML 响应,我遵循了示例 here

我还按照this 示例生成证书,以及生成然后签署我的 SAML 响应。但是,为了修复我的实现,我将签名方法更改为 SHA1。

为了提交我的表单,我将代码隐藏中的值绑定到一个 HTML 表单,该表单本质上是这样发布的:

  <form method="post" action="https://{myhub}.influitive.com/saml/consume" />
    <input type="hidden" name="SAMLResponse" value="{Base64EncodedStringofSAMLResponse}" />
    <input type="hidden" name="RelayState" value="https://{myhub}.influitive.com/about" />
</form>

<script>
    if ("{Base64EncodedStringofSAMLResponse}" != "") {
        window.onload = function () {
            document.forms[0].submit();
        }
    }
</script>


问题是每当我的表单 POST 时,我不断收到 500 Internal Server 错误,即使我的 SAML 响应已正确形成、签名和编码。我该如何解决这个问题?

【问题讨论】:

    标签: c# single-sign-on saml


    【解决方案1】:

    问题实际上来自我的 SAML 响应中不必要的“发行人”标签。

    我根据我在网上找到的示例包括了其中两个。 我取出了 Issuer 标签的第一个实例,但将第二个实例留在了 Assertion 标签内,并且它起作用了。 有影响力的支持人员查找了我的集线器的日志,并向我发送了一条错误消息,大致说明了这一点。

    以下是格式正确、签名的 SAML 响应示例。

    <samlp:Response 
    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" 
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    Destination="https://{YOURHUB}.influitive.com/saml/consume" 
    ID="{A GUID}" 
    IssueInstant="{CURRENT UTC TIME}" 
    Version="2.0" 
    InResponseTo="{ID of Influitive SAMLRequest, or leave blank for IdP initiated SSO}">
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
        <SignedInfo>
            <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
            <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
            <Reference URI="#_f44dfe01e93143d7b1e1b9e826ace708">
                <Transforms>
                    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                </Transforms>
                <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                <DigestValue>{The DigestValue}</DigestValue>
            </Reference>
        </SignedInfo>
        <SignatureValue>{The SignatureValue}<SignatureValue>
        <KeyInfo>
            <X509Data>
                <X509Certificate>{The X509Cert}</X509Certificate>
            </X509Data>
        </KeyInfo>
    </Signature>
    <samlp:Status>
        <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
    </samlp:Status>
    <saml:Assertion 
        ID="{A SECOND GUID}" 
        IssueInstant="{CURRENT UTC TIME}" 
        Version="2.0">
        <saml:Issuer>{Name of the Issuer. Shouldn't really matter}</saml:Issuer>
        <saml:Subject>
            <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" NameQualifier="Influitive-AdvocateHub">example@gmail.com</saml:NameID>
            <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                <saml:SubjectConfirmationData NotOnOrAfter="{CURRENT UTC TIME + 1 MINUTE}" Recipient="https://{YOURHUB}.influitive.com/saml/consume" InResponseTo="{ID of Influitive SAMLRequest, or leave blank for IdP initiated SSO}" />
            </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Conditions NotBefore="{CURRENT UTC TIME}" NotOnOrAfter="{CURRENT UTC TIME + 1 MINUTE}">
            <saml:AudienceRestriction>
                <saml:Audience>Influitive-AdvocateHub</saml:Audience>
            </saml:AudienceRestriction>
        </saml:Conditions>
        <saml:AuthnStatement AuthnInstant="{CURRENT UTC TIME}">
            <saml:AuthnContext>
                <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
            </saml:AuthnContext>
        </saml:AuthnStatement>
        <saml:AttributeStatement>
            <saml:Attribute Name="FirstName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue xsi:type="xs:string">{SOME FIRST NAME}</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="LastName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue xsi:type="xs:string">{SOME LAST NAME}</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="Email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue xsi:type="xs:string">{example@gmail.com}</saml:AttributeValue>
            </saml:Attribute>
        </saml:AttributeStatement>
    </saml:Assertion>
    

    如果您对如何生成此 SAML 响应、如何使用证书签名、编码或任何其他问题有任何疑问,请告诉我!这是一个巨大的 PITA,我很乐意有机会帮助其他人。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2010-10-22
      • 2022-08-17
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 2014-10-23
      相关资源
      最近更新 更多