spring 使用 ADFS 的安全 saml 扩展中关于 XML ID 的问题

issue in spring security saml extension with ADFS about the XML ID

大家~!最近我建了一个项目,使用springsecurity saml扩展作为SP,ADFS作为idp,springsecurity saml扩展创建的AuthnRequest xml是像这样:

<?xml version="1.0" encoding="UTF-8"?>
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
    AssertionConsumerServiceURL="http://127.0.0.1:8080/sp"
    ForceAuthn="false" ID="9135430817744047388" IsPassive="false"
    IssueInstant="2016-11-17T06:20:05.912Z"
    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
    Version="2.0">
    <samlp:Issuer xmlns:samlp="urn:oasis:names:tc:SAML:2.0:assertion">
        test
    </samlp:Issuer>
    <saml2p:NameIDPolicy
        xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" AllowCreate="true"/>
</samlp:AuthnRequest>

当我将这个 SAMLRequest 发送到 ADFS 服务器时,服务器响应一个类似 "urn:oasis:names:tc:SAML:2.0:status:Responder" 的错误并且没有断言 content.For 测试,我用 OpenSAML 写了一些 java 代码来创建 AuthnRequest xml,然后更改属性

ID="9135430817744047388"

ID="_9135430817744047388"

然后一切正常 well.It 似乎 ID 中的字符 _ 会影响结果。 所以我的问题是,如何更改 spring security saml 扩展中的 ID 属性以在 ID 前面添加 _

我弄错了,与字符_无关,而是请求的符号类型,因为metadatagenerator的属性requestSigned设置为true 默认情况下,spring saml 会在http post 请求中添加SigAlgSignature 参数,然后adfs 服务器会检查SP 在IDP 中注册的证书,虽然我不向 IDP 提供客户端证书。 Resolution:set 属性 requestSignedfalse,因此 spring saml 不会发送 SAMLRequest 的签名并且一切正常。