身份服务器和 ADFS

IdentityServer and ADFS

我正在尝试将 IdentityServer 设置为使用 ADFS 进行身份验证。流程将是:

用户 -> 自定义应用程序 -> IS -> ADFS

我已经设置了几乎所有的东西,但是我卡在了 IS 和 ADFS 之间的通信上。用户似乎在 ADFS 中成功登录,但出现错误:

ID4037:无法从以下安全密钥标识符解析验证签名所需的密钥“SecurityKeyIdentifier

当我回到 IS 时。

很明显,一侧或另一侧的令牌签名证书存在问题。我试图找到一些解释不同证书之间关系的文档,但没有成功。

现在我在 IS 中有一个自签名证书,它正在签署令牌(使用 IdentityServerOptions 的 SigningCertificate 属性 设置)并且我在 ADFS 中配置了一个 AD 证书来签署令牌。

是否有关于如何正确执行此操作的指南或建议?两者应该相同还是我应该配置其他东西以使其工作?

编辑 使用 Fiddler,我可以看到 ADFS 中的所有内容都运行良好,错误出现在将结果发布到 IdentityServer 时。在 wresult 参数中发布的 XML 是:

<t:RequestSecurityTokenResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
  <t:Lifetime>
    <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-06-20T12:25:31.148Z</wsu:Created>
    <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-06-20T13:25:31.148Z</wsu:Expires>
  </t:Lifetime>
  <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
    <wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Address>urn:identityServer</wsa:Address>
    </wsa:EndpointReference>
  </wsp:AppliesTo>
  <t:RequestedSecurityToken>
    <saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_fd1a14cd-4d18-407b-97d4-9f9dfcacd29a" Issuer="http://ssosrv.mydomain.com/adfs/services/trust" IssueInstant="2017-06-20T12:25:31.148Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
      <saml:Conditions NotBefore="2017-06-20T12:25:31.148Z" NotOnOrAfter="2017-06-20T13:25:31.148Z">
        <saml:AudienceRestrictionCondition>
          <saml:Audience>urn:identityServer</saml:Audience>
        </saml:AudienceRestrictionCondition>
      </saml:Conditions>
      <saml:AttributeStatement>
        <saml:Subject>
          <saml:NameIdentifier>user@mydomain.com</saml:NameIdentifier>
          <saml:SubjectConfirmation>
            <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
          </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Attribute AttributeName="emailaddress" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
          <saml:AttributeValue>name.surname@mydomain.tv</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="name" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
          <saml:AttributeValue>Name Surname</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="upn" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
          <saml:AttributeValue>user@mydomain.com</saml:AttributeValue>
        </saml:Attribute>
      </saml:AttributeStatement>
      <saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" AuthenticationInstant="2017-06-20T12:25:31.039Z">
        <saml:Subject>
          <saml:NameIdentifier>user@mydomain.com</saml:NameIdentifier>
          <saml:SubjectConfirmation>
            <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
          </saml:SubjectConfirmation>
        </saml:Subject>
      </saml:AuthenticationStatement>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
          <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
          <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
          <ds:Reference URI="#_fd1a14cd-4d18-407b-97d4-9f9dfcacd29a">
            <ds:Transforms>
              <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
              <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
            <ds:DigestValue>6CeXXXXXXXXXXXXXXXXXXXX=</ds:DigestValue>
          </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>q9hJBFFFFFFFFFFFFFFFFFFFF==</ds:SignatureValue>
        <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
          <X509Data>
            <X509Certificate>MIIFnzXXXXXXXXXXXXXXXXXXXX</X509Certificate>
          </X509Data>
        </KeyInfo>
      </ds:Signature>
    </saml:Assertion>
  </t:RequestedSecurityToken>
  <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
  <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
  <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
</t:RequestSecurityTokenResponse>

谢谢, 艾伯特

凭记忆:

  • 您需要将IS证书转换为.cer格式。
  • 在 mmc 中,右键单击证书和“所有任务”/“导出”。
  • 单击“导出向导”选择: “不,不要导出私钥”。 “DER 编码二进制 X.509 (.CER)”。
  • Select 要导出到的文件名并“保存”。
  • 查看选项并“完成”。
  • 在 ADFS 向导中,将 .cer 文件导入“证书”选项卡。

解决了。它与 ADFS 集成无关,而是我如何在 Identity Server 中设置联合身份验证。我使用了两个联合身份验证身份提供程序:一个使用 ADFS,另一个使用 WinAuth。如果没有回调,来自 ADFS 的响应将由 WinAuth 处理,因此我为每个回调配置了不同的回调并且它正在工作。