2012-04-19 79 views
0

我試圖在以下情況下在WCF中找到標準解決方案:WCF定製認證 - 令牌

我有2個服務。 Service1想要向service2發送請求。我希望service1將發送憑證,以便在service2響應他的請求之前進行身份驗證。

我不想使用ssl或在所有網絡服務之間複製證書。

這是我的解決方案:

我將創建一個「安全服務」。

Service1將根據安全服務進行身份驗證。

成功驗證後,此安全服務將爲service1提供由安全服務簽名的自定義令牌。

Service1會將此令牌附加到它的每個請求中。

Service2將驗證此令牌,如果成功,將處理請求。

答案是如果在C#(WCF)中有一種方法來實現這種機制。

感謝

+0

看到這個問題:http://stackoverflow.com/questions/964433/how-to-add-a-custom-header-to-every-wcf-calls – Jaapjan 2012-04-19 08:31:14

回答

0

如果你在談論WCF服務,看看哪種安全WCF supports。它是None,Transport,Message,TransportWithMessageCredential,TransportCredentialOnly,Both。你說你對運輸安全不感興趣。所以,列表中仍然有消息安全性。

WCF supports the following credential types when you are using message level security: 

Windows. The client uses a Windows token representing the logged in user’s Windows identity. The service uses the credentials of the process identity or an SSL certificate. You will use this in the sample application that demonstrates the first scenario (internal self-hosted service). 
UserName. The client passes a user name and password to the service. Typically, the user will enter the user name and password in a login dialog box. The service can validate the user name and password using a Windows account or the ASP.NET membership provider. You will use this in the sample application that demonstrates the third scenario (public Web-hosted service). 
Certificate. The client uses an X.509 certificate and the service uses either that certificate or an SSL certificate. 
IssueToken. The client and service use the Secure Token Service, which issues tokens the client and service trust. Windows CardSpace uses the Secure Token Service. 
None. The service does not validate the client. 

下一頁你沒有說什麼,但確定身份驗證類型是很重要的,這是你將如何來承載您的服務,特別是服務2. Windows身份驗證是良好的內部自我託管服務,但我我不確定這是你的情況。所以,如果你的服務將在IIS上託管,用戶名就適合你。並支持digest authentication是你需要的。閱讀Digest Authentication on a WCF REST Service。如果它不是IIS託管服務,或者您需要其他解決方案,則可以使用Security Token Service。但最新的更好的解決方案是基於聲明的身份驗證,您可以在其他答案中找到鏈接。

+0

我想使用我自己的自定義身份驗證類型。只有當service1從認證服務請求令牌時,認證纔會完成。 – fransua 2012-04-19 10:45:59