wcf - 如何为各种部署更改我的 WCF 的 FederationMetadata.xml 文件?

标签 wcf web-services adfs2.0 federated-identity

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

我们现在开始公开一些安全的 Web 服务,并希望利用相同的身份验证系统。我的理解是我想使用 ws2007FederationHttpBinding作为我这样做的约束力。我相信我已经为此设置了所有 WCF 的 web.config,但我现在的努力集中在 FederationMetadata.xml 上。文件。

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

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

  • 个人开发人员工作站(现在是 3x,以后会更多)
  • 一个共享的开发环境,供人们针对这些服务编写应用程序但不一定修改服务
  • 质量保证
  • 分期
  • 生产(具有不同证书/域/等的 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>
    

    最佳答案

    基于 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 自动生成。

    关于wcf - 如何为各种部署更改我的 WCF 的 FederationMetadata.xml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7650537/

    相关文章:

    c# - 如何在 C# WCF REST POST 中的 StreamReader.ReadToEnd() 之后抛出 WebFaultException?

    c# - WCF 不反序列化。为什么我的参数是 NULL?

    ADFS v2.0 : Finding errors referenced by the reference number

    java - inputStream 编码问题(特殊字符 : ñ, á,...)

    python - 是否有任何 URL 信息/元数据网络服务 API?

    single-sign-on - WIF 使用 SAML 2 协议(protocol)/Federate AD FS 2.0 with CAS

    saml - PingFederate 和 ADFS 是否支持 ECP(增强型客户端和代理)配置文件?

    c# - 在具有相同终结点名称的不同用户 session 中运行的 net pipe WCF 服务

    c# - StructureMap(或任何 IoC)和 WCF

    .net - 在 IIS 中添加 net.pipe 绑定(bind)时出现 "Object reference not set"