【发布时间】:2011-08-19 16:30:17
【问题描述】:
我想使用许可证密钥针对我的中心对应用服务器进行身份验证,并且我不想将其作为参数包含在我的调用中。
我已经实现了自定义 ServiceAuthorizationManager,但我不确定在客户端设置此 licenseKey 的最佳方式和位置是什么。
我在下面尝试过(我的方法可能完全错误)
<endpoint address="http://127.0.0.1:8000/ApiDataService" binding="wsHttpBinding"
contract="MyInterfaces.IApiDataService">
<headers>
<LicenseKey>MyLicenseKey</LicenseKey>
</headers>
</endpoint>
然后在ServiceAuthorizationManager.CheckAccessCore(OperationContext operationContext)中
我已设法通过以下方式找到标题的索引:
operationContext.RequestContext.RequestMessage.Headers.FindHeader("LicenseKey", "")
但检索到的 HeaderInfo 不再包含我的内容。 我确定它在 operationContext.RequestContext 中,所以我应该能够以某种方式捕获它。
- 知道怎么做吗?
- 有没有更好/标准的方法来做到这一点?
- 我应该使用
元素吗?
我非常乐意使用 operationContext.ServiceSecurityContext,但我不知道如何在客户端设置它以及在哪里放置我的自定义许可证密钥。
我有多个端点,所以我希望有一个地方存放我的许可证密钥。从代码中设置会更好。
谢谢
【问题讨论】:
标签: wcf security authentication endpoint