2011-10-04 67 views
6

我們有一個ADFS 2.0安裝,在我們的各種環境中適用於我們的MVC應用程序。我相信它使用「被動認證」(我仍然習慣於正確的術語) - 如果用戶沒有登錄,並且adfs將用戶重定向到我們的MVC應用程序,它肯定是將用戶重定向到我們的adfs代理的位置一旦他們登錄了。如何爲各種部署更改我的WCF的FederationMetadata.xml文件?

我們現在開始公開一些安全的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> 

回答

1

基於WIF的應用程序的FederationMetadata.xml與它提供的基於聲明的網絡服務無關。

(指向一個URL)FederationMetadata.xml被AD FS用來自動更新要在信賴方信任中使用的信息。 AD FS可以例如定期查詢此URL,並相應地更新依賴方信任信息。

有關Web服務(基於聲明或其他)的信息(即其元數據)作爲WSDL文檔發佈。在基於WCF的服務中,這是一個經常如下所示的URL:http://myhost.example.com/appName/serviceName.svc?wsdl。 WSDL文檔通常不作爲物理文件存在,而是由WCF自動生成。

+0

是的,我知道這與WSDL無關。但是,這與環境有很大關係。原始呈現的FederationMetadata.xml在其中多次包含「http:// localhost /」,這顯然是錯誤的,需要針對每個不同的部署位置進行更改。我不知道如何改變其中的一些內容,例如EntityDescriptor ID或SignatureValue。這是我需要幫助理解的。 – Jaxidian

+0

您似乎想要使用WIF和AD FS來保護WCF Web服務。我的觀點很簡單,就是你不需要'FederationMetadata.xml':該文件不用於任何Web服務通信。你也可以從你的應用程序中刪除這個文件,並且一切仍然有效。 –

+0

這樣做意味着我必須使用ADFS 2.0手動配置所有內容,而不是使用XML進行配置,對嗎?作爲RP它仍然可以正常工作嗎?如果是這樣的話,那麼其實在其他地方只能提出同樣的問題。所以現在我想,我需要知道如何在ADFS管理工具中手動配置RP。 – Jaxidian

0

我發現我的問題部分回答in this blog post。我正在研究它是否能夠解答我的所有問題。我剛剛找到它。顯然,我需要更改我的EntityID(包含URL),因爲我重新將其部署到不同的環境中,但SignatureValue包含該URL的散列(等等),所以通過修改URL,我無效SignatureValue,它需要被再生。顯然這FederationMetadata Generator可以幫助我。

相關問題