【问题标题】:Invalid SAML AuthN RequestSAML AuthN 请求无效
【发布时间】:2019-05-10 10:00:33
【问题描述】:

通过尝试使用 ADFS 在我的 SP 和 IDP 之间建立 SSO 连接(sp 启动),我无法从 IDP 获得答案。问题是这个 IDP 是一个黑匣子,我没有手。

所以做了一些调试,我使用this 工具检查了我的查询是否有效并且格式正确,并收到了这条消息

无效的 SAML AuthN 请求。与 saml-schema-protocol-2.0.xsd 不匹配

但是他们没有更多的细节,即使我检查saml protocol schema,我也找不到这个请求的问题所在:

<samlp:AuthnRequest 
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
    ID="_2e674db5054e407c30af" 
    Version="2.0" 
    IssueInstant="2019-05-10T09:39:52Z" 
    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 
    AssertionConsumerServiceURL="https://my-sp.com/callback">
    <saml:Issuer 
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">sp_name
    </saml:Issuer>
    <samlp:NameIDPolicy 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified" 
        AllowCreate="true">
    </samlp:NameIDPolicy>
    <samlp:RequestedAuthnContext 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        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:RequestedAuthnContext>
</samlp:AuthnRequest>

我是否遗漏了一个必填字段或某个值的格式不正确?

【问题讨论】:

    标签: xml xsd single-sign-on saml-2.0


    【解决方案1】:

    首先,您应该使用 Validate XML with the XSD schema 工具。当我这样做时,我得到了:

    Line: 14 | Column: 0 --&gt; Element '{urn:oasis:names:tc:SAML:2.0:protocol}NameIDPolicy': Character content is not allowed, because the content type is empty.

    所以,我删除了标签 &lt;/samlp:NameIDPolicy&gt; 并关闭了您的 NameIDPolicy,如下所示:

    <samlp:AuthnRequest 
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
    ID="_2e674db5054e407c30af" 
    Version="2.0" 
    IssueInstant="2019-05-10T09:39:52Z" 
    ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 
    AssertionConsumerServiceURL="https://my-sp.com/callback">
    <saml:Issuer 
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">sp_name
    </saml:Issuer>
    <samlp:NameIDPolicy 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified" 
        AllowCreate="true" />
    <samlp:RequestedAuthnContext 
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
        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:RequestedAuthnContext></samlp:AuthnRequest>
    

    希望对你有帮助

    【讨论】:

    • 谢谢,不知道不允许留空内容。但是现在我得到了“解析 xml 字符串时出错”,你知道它是从哪里来的吗?
    • @PopHip 对不起,我的错误,我忘记粘贴结束标签 &lt;/samlp:AuthnRequest&gt;。我已经编辑了我的答案。
    • 啊,对了,问题来了!感谢请求现在有效
    猜你喜欢
    • 2020-02-26
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    • 2020-03-05
    • 1970-01-01
    相关资源
    最近更新 更多