HTTP 重定向绑定 SAML 请求

ton*_*919 5 x509certificate single-sign-on saml-2.0

假设执行了 SP-init SSO,使用 HTTP-Redirect Binding 代替 HTTP-POST Binding 并且需要签名的 AuthnRequest。这意味着在 URL 中包含 SAMLRequest。

一季度。我需要在 URL 中包含签名还是只嵌入到 SAMLRequest 中?

重定向网址是

http://idp.example.com/SSOService.php?SAMLRequest= {val1}&Signature={val2}&SigAlg={val3}

使用我的 SAMLRequest(无签名)

<samlp:AuthnRequest ID="" Version="2.0" IssueInstant="2015-05-22T02:47:38Z" Destination="" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"></saml:Issuer>
    <samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" AllowCreate="true" />
    <samlp:RequestedAuthnContext Comparison="exact" />
    <saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</samlp:AuthnRequest>
Run Code Online (Sandbox Code Playgroud)

或者

http://idp.example.com/SSOService.php?SAMLRequest= {val1}

使用我的 SAMLRequest(嵌入签名)

<samlp:AuthnRequest ID="" Version="2.0" IssueInstant="2015-05-22T02:47:38Z" Destination="" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
    <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"></saml:Issuer>
    <samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" AllowCreate="true" />
    <samlp:RequestedAuthnContext Comparison="exact" />
    <saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
    <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="">
                <Transforms>
                    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                </Transforms>
                <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                <DigestValue>v5h...</DigestValue>
            </Reference>
        </SignedInfo>
        <SignatureValue>M4...</SignatureValue>
    </Signature>
</samlp:AuthnRequest>
Run Code Online (Sandbox Code Playgroud)

Q2。将 base64 和 url 编码为 url 参数的值是否正确?

Q3。X509 证书包含在我的 SP 元数据中,它是 base64 编码的吗?

我有一个证书的 cert.pem 文件,我需要将其设为 base64 编码还是直接包含证书。

-----BEGIN CERTIFICATE-----
MII...
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)

SPMetadata.xml

<KeyDescriptor use="signing">
            <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:X509Data>
                    <ds:X509Certificate>MIIFnzCCA4egAwI...</ds:X509Certificate>
                </ds:X509Data>
            </ds:KeyInfo>
        </KeyDescriptor>
Run Code Online (Sandbox Code Playgroud)

Han*_* Z. 6

A1:使用重定向绑定时,您将签名放在 URL 查询参数中

A2:所有的 URL 查询参数都应该是 url 编码的,除了 SAML 请求应该被压缩和 base64 编码。

A3:使用 PEM 格式,因为它已经是 base64 编码的,但省略了开始和结束分隔符(----BEGIN-- 和----END CERT ...)