使用 x509 和多个客户端设置 Web 服务以及如何区分客户端? [英] Setting up web services with x509 and multiple clients and how to distinguish clients?

查看:24
本文介绍了使用 x509 和多个客户端设置 Web 服务以及如何区分客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循这些两个 链接,我能够实现一个具有 x509 认证的简单 Web 服务,以及一个使用该服务的经过身份验证的测试客户端.

Following these two links, I was able to implement a simple web service with x509 certification, and an authenticated test client to consume the service.

现在,它看起来像这样:

Right now, it looks something like this:

 --------------
| ServiceA.svc | ------------> Test Client 1
|  -GetData()  |
 --------------

如何扩展我必须完成的工作:

How can I extend what I have to accomplish something like this:

 --------------
| ServiceA.svc | ------------> Test Client 1
|  -GetData()  | ------------> Test Client 2
|  -SaveData() |
 --------------
| ServiceB.svc |-------------> Test Client 1
|  -GetData()  |
 --------------
| ServiceC.svc |-------------> Test Client 2
|  -SaveData() |
 --------------

我已经设置了服务,可以使用测试客户端 2.

I already have services set up, and Test Client 2 ready to go.

以下是我的一些问题:

  • 我是否需要为测试客户端 2 创建单独的证书?
  • 配置文件/端点/行为会是什么样子?我认为 Service B 和 C 会很容易设置,因为它与我现在拥有的基本相同,但是现在 ServiceA 将被两个客户端使用,我有点迷茫.
  • 如果调用了 ServiceA,我如何知道哪个客户端正在调用它?我可能想限制他们可以调用的方法(即 TC1 只能使用 GetData(),TC2 只能使用 SaveData()),并且能够记录谁正在访问这些方法.

如果需要,我可以在配置文件中发布我拥有的内容,但它看起来基本上是上述两个链接所具有的内容.

I can post what I have on the config files if needed, but it looks basically what the two aforementioned links have.

推荐答案

是的,每个客户端都需要一个单独的证书.然后从操作中你可以得到它的区别标识:

yes, each client needs a separate certificate. Then from within the operation you can get its distinguished identity:

ServiceSecurityContext.Current.PrimaryIdentity.Name

最佳做法是将授权过程分开,如下所述:http://msdn.microsoft.com/en-us/magazine/cc948343.aspx

The best practice is to separate the authorization process like described here: http://msdn.microsoft.com/en-us/magazine/cc948343.aspx

这篇关于使用 x509 和多个客户端设置 Web 服务以及如何区分客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆