如何更改我的WCF的FederationMetadata.xml文件以进行各种部署?

Jax*_*ian 6 wcf web-services federated-identity adfs2.0

我们有一个ADFS 2.0安装,适用于我们各种环境中的MVC应用程序.我相信它使用"被动身份验证"(我仍然习惯于正确的术语) - 如果用户未登录并且adfs将用户重定向回我们的MVC应用程序,它肯定会将用户重定向到我们的adfs代理一旦他们登录.

我们现在开始公开一些安全的Web服务,并希望利用这个相同的身份验证系统.我的理解是,我想用它ws2007FederationHttpBinding作为我的绑定来做到这一点.我相信我有我的WCF的web.config所有设置,但我的斗争现在围绕FederationMetadata.xml文件.

看一下这个文件,我看到一些显然需要改变的东西,比如entityID="http://localhost/UserServices"证书.然后有些事我不知道它们是什么,是否需要改变,例如EntityDescriptor ID="_2b510fe8-98b8......<ds:SignatureValue>CZe5mEu19/bDNoZrY8f6C559CJ........

在哪里可以更好地了解如何为各种环境管理此文件?我有以下托管这些服务的环境,我们将以这种或那种方式进行部署:

  1. 各个开发人员工作站(现在是3倍,之后更多)
  2. 针对这些服务编写应用程序但不一定修改服务的人员的共享开发环境
  3. QA
  4. 分期
  5. 生产(具有不同证书/域/等的3种不同环境)

因此,我们有一个相当简化的流程,使用转换和查找/替换某些令牌来管理不同环境中的web.config文件,因此我想对此xml文件执行相同的操作.因此,最终,我正在寻找的是在FederationMetadata.xml为各种环境管理此文件时需要进行哪些更改.

我当前的FederationMetadata.base.xml文件在下面,我相信这是正确的(我只需要名称/角色),我只需要智能地替换各种令牌,例如~RootServiceUrlTokenToReplace~,在这里:

<?xml version="1.0" encoding="utf-8"?>
<EntityDescriptor ID="~EntityDescriptorIdTokenToReplace~" entityID="http://~RootServiceUrlTokenToReplace~" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
  <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="#~ReferenceURITokenToReplace~">
        <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>~DigestValueTokenToReplace~</ds:DigestValue>
      </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue>~SignatureValueTokenToReplace~</ds:SignatureValue>
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <X509Data>
        <X509Certificate>~CertificateTokenToReplace~</X509Certificate>
      </X509Data>
    </KeyInfo>
  </ds:Signature>
  <RoleDescriptor xsi:type="fed:ApplicationServiceType" protocolSupportEnumeration="http://schemas.xmlsoap.org/ws/2005/02/trust http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fed="http://docs.oasis-open.org/wsfed/federation/200706">
    <KeyDescriptor use="encryption">
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <X509Data>
          <X509Certificate>~CertificateTokenToReplace~</X509Certificate>
        </X509Data>
      </KeyInfo>
    </KeyDescriptor>
    <fed:ClaimTypesRequested>
      <auth:ClaimType Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" Optional="true" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" />
      <auth:ClaimType Uri="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" Optional="true" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" />
    </fed:ClaimTypesRequested>
    <fed:TargetScopes>
      <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
        <Address>http://~RootServiceUrlTokenToReplace~</Address>
      </EndpointReference>
    </fed:TargetScopes>
    <fed:ApplicationServiceEndpoint>
      <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
        <Address>http://~RootServiceUrlTokenToReplace~</Address>
      </EndpointReference>
    </fed:ApplicationServiceEndpoint>
  </RoleDescriptor>
</EntityDescriptor>
Run Code Online (Sandbox Code Playgroud)

Mar*_*ica 1

基于 WIF 的应用程序FederationMetadata.xml与其提供的基于声明的 Web 服务无关。

(指向的 URL)FederationMetadata.xml由 AD FS 使用,以自动更新要在依赖方信任中使用的信息。例如,AD FS 可以定期查询此 URL,并相应地更新依赖方信任信息。

有关 Web 服务的信息(基于声明的或其他方式),即其元数据,作为 WSDL 文档发布。在基于 WCF 的服务中,该 URL 通常如下所示:http://myhost.example.com/appName/serviceName.svc?wsdl。该 WSDL 文档通常不作为物理文件存在,而是由 WCF 自动生成。