2012-04-19 108 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