如何使用表单身份验证和安全性对 WCF 调用进行身份验证

发布于 2024-10-11 08:10:45 字数 696 浏览 2 评论 0原文

我正在计划设置一个跨多台计算机的分布式应用程序,并将使用 WCF 在它们之间发送数据。

计算机 A

计算机 B

计算机 C

计算机上的 WCF 服务B 和机器 C 应检查来自机器 A 的请求是否已通过身份验证。我如何检查请求是否在不同的机器上经过身份验证?

我只关心请求是否经过身份验证,而不关心消息正文的安全(因为我们不会通过网络发送任何敏感数据),因此不需要 SSL。

对于上述场景,我可以使用哪些身份验证方法?

I'm planning a set up for a distributed application that spans several machines and will use WCF to send data in between.

Machine A

Machine B

Machine C

The WCF services on Machine B and Machine C should check that the request from Machine A has been authenticated. How can i check that the request is authenticated across the different machines?

I only care that the request is authenticated and not concerned about securing the message body (because we are not sending any sensitive data across the wire), so SSL is not required.

What authentication methods can i use for the above scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流殇 2024-10-18 08:10:45

这取决于您的解决方案的复杂程度和安全程度。 WCF 还可以根据成员资格提供者验证用户。这种情况要求您将用户凭据传递给每个 WCF 服务调用,最后您将再次在每个层上对用户进行身份验证。这将不起作用,因为 Web 应用程序仅对一个请求使用凭据,后续请求在 cookie 中具有身份验证令牌。但 WCF 要求对每个调用进行身份验证。因此,当在 WCF 中使用成员资格提供程序时,您需要将用户凭据存储在机器 A 上的会话中。我真的不喜欢将整个会话的客户端凭据存储在内存中的某个位置。

我可能会使用类似的内容:

低安全场景:

您提到您正在构建分布式应用程序,因此您的各层(机器 A - C)之间应该存在某种信任。机器 A 是否允许匿名访问?如果不是,机器 B 上的层是否可以信任机器 A 上的层对用户进行了身份验证? C和B也一样吗?在这种情况下,您根本不需要处理机器 B 和 C 上的身份验证,而是使用 Windows 安全性仅允许访问运行客户端层的帐户(A 是 B 的客户端,B 是 C 的客户端)。

高安全场景:

通常在您希望避免有人入侵机器 A 上的网络并在这种情况下对机器 B 上的所有操作进行身份验证的情况下使用,或者当您需要基于用户的原始身份进行授权时使用此选项。

您不会在机器 A 上执行直接身份验证。相反,机器 A 上的自定义成员资格提供程序(或直接表单身份验证)将调用机器 B 上的身份验证服务。该服务将为“安全会话”创建令牌。根据实现,此令牌只能用于 A 和 B 之间的通信(您必须将其存储在会话中)或客户端、A 和 B 之间的整个通信(您将在 cookie 中传递它)。机器 C 信任机器 B。这可以进一步扩展到完全联邦场景。

这不会避免会话劫持(在客户端和机器 A 之间使用令牌嗅探 cookie - 为了避免这种情况,您需要在客户端和 A 之间使用 HTTPS),但如果没有令牌,黑客就可以在您的机器 B 或 C 上做任何事情。

It depends on how complex and secured your solution should be. WCF can also validate user based on membership provider. Such scenario requires that you pass user credentials to each WCF service call and at the end you will authenticate user on each layer again. This will not work because Web application uses credentials only for one request and subsequent requests have authentication token in cookie. But WCF requires authentication of each call. So when using membership provider in WCF you need to store user credentials in session on Machine A. I really don't like the idea of storing client credentials somewhere in memory for whole session.

I would probably use something like:

Low security scenario:

You mentioned that you are building distributed application so there should propably be some kind of trust among your tiers (Machine A - C). Is anonnymous access allowed on Machine A? If not, can your tier on Machine B trust tier on Machine A that it authenticated users? Same with C and B? In such case you don't need to deal with authentication on Machine B and C at all and instead use Windows security to allow access only to account running client tier (A is client of B, B is client of C).

High security scenario:

This is usually used when you want to avoid situation when somebody hacks web on Machine A and in such case is authenticated for all actions on Machine B or when you need authorization based on user's original identity.

You will not perform direct authentication on Machine A. Instead custom membership provider (or direct forms authentication) on Machine A will call authentication service on Machine B. The service will create token for "security session". Based on implementation this token can be used only for communication between A and B (you have to store it in session) or for whole communication between client, A and B (you will pass it in cookie). Machine C trusts Machine B. This can be futher extended to full federated scenario.

This will not avoid session hijacking (sniffing cookie with token between client and Machine A - to avoid this you need HTTPS between client and A) but without token, hacker can do anything on your Machine B or C.

丿*梦醉红颜 2024-10-18 08:10:45

典型的设置是计算机 A 使用单个技术用户连接到计算机 B 和 C 上的 WCF 服务。为此,可以将用户名和密码放入计算机 A 的配置文件中,或者如果所有计算机都是 Windows 身份验证,则使用 Windows 身份验证。在同一域内。

机器 B 和 C 将简单地信任机器 A 请求已经过身份验证。

A typical setup would be that machine A uses a single technical user to connect to the WCF service on machine B and C. For that use either put the username and password in the configuration file of machine A or you use Windows Authentication if all machines are within the same domain.

Machines B and C will simply trust machine A that the request has been authenticated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文