【问题标题】:SAML Response - What needs to be verified to ensure the response can be trusted?SAML 响应 - 需要验证什么以确保响应可信?
【发布时间】:2016-05-13 00:27:54
【问题描述】:

抱歉,如果这些看起来是重复的,但我一直在搜索帖子,但我找不到我正在寻找的确切内容。

我的 Web 应用程序正在向 Azure 发送身份验证请求以进行单点登录。收到响应后,需要验证哪些字段和属性以确保断言可以信任,为什么?

Microsoft 文档中的示例响应在这里-

<samlp:Response ID="_a4958bfd-e107-4e67-b06d-0d85ade2e76a" Version="2.0" IssueInstant="2013-03-18T07:38:15.144Z" Destination="https://contoso.com/identity/inboundsso.aspx" InResponseTo="id758d0ef385634593a77bdf7e632984b6" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    ...
  </ds:Signature>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
  <Assertion ID="_bf9c623d-cc20-407a-9a59-c2d0aee84d12" IssueInstant="2013-03-18T07:38:15.144Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
    <Issuer>https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
      ...
    </ds:Signature>
    <Subject>
      <NameID>Uz2Pqz1X7pxe4XLWxV9KJQ+n59d573SepSAkuYKSde8=</NameID>
      <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <SubjectConfirmationData InResponseTo="id758d0ef385634593a77bdf7e632984b6" NotOnOrAfter="2013-03-18T07:43:15.144Z" Recipient="https://contoso.com/identity/inboundsso.aspx" />
      </SubjectConfirmation>
    </Subject>
    <Conditions NotBefore="2013-03-18T07:38:15.128Z" NotOnOrAfter="2013-03-18T08:48:15.128Z">
      <AudienceRestriction>
        <Audience>https://www.contoso.com</Audience>
      </AudienceRestriction>
    </Conditions>
    <AttributeStatement>
      <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
        <AttributeValue>testuser@contoso.com</AttributeValue>
      </Attribute>
      <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
        <AttributeValue>3F2504E0-4F89-11D3-9A0C-0305E82C3301</AttributeValue>
      </Attribute>
      ...
    </AttributeStatement>
    <AuthnStatement AuthnInstant="2013-03-18T07:33:56.000Z" SessionIndex="_bf9c623d-cc20-407a-9a59-c2d0aee84d12">
      <AuthnContext>
        <AuthnContextClassRef> urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
      </AuthnContext>
    </AuthnStatement>
  </Assertion>
</samlp:Response>

到目前为止我所知道的。

  • 您必须验证签名以确保消息未被修改。
  • 您必须验证证书公钥是否来自受信任的来源,否则任何有效签名的证书都会进行身份验证。

还有什么?

【问题讨论】:

    标签: azure saml saml-2.0


    【解决方案1】:
    • 签名 - 记得check the references
    • 验证证书是否来自正确的对等方(您自己也注意到了)
    • 断言的条件。

    我建议您不要为此编写自己的代码,而是使用现有的 SAML2 SP 库。做好这一切需要做很多工作(我已经完成了,如果我知道它有多少工作,我不确定我是否会这样做)。

    【讨论】:

    • 安德斯太谦虚了,没有提到他自己的图书馆github.com/KentorIT/authservices。如果您在该库中进行深入研究,您可以找到直接验证和解压缩令牌的模块 - 如果需要 - 或者如果合适的话,只需让库为该站点完成所有工作。它非常棒,我在多个系统的生产环境中使用它。
    • 感谢您提供有关检查参考的信息的链接,我发现它非常有见地 - 绝对是我错过的检查!
    猜你喜欢
    • 1970-01-01
    • 2021-04-15
    • 2014-07-20
    • 2018-12-11
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多