我想使用许可证密钥针对我的中心验证应用程序服务器,并且我不想将其作为参数包含在我的调用中。
我已经实现了自定义 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 中,所以我应该能够以某种方式捕获它。
- 任何想法如何?
- 有没有更好/标准的方法来做到这一点?
- 我应该使用 <identity\> 元素吗?
我非常乐意使用 operationContext.ServiceSecurityContext 但我不知道如何在客户端设置它以及在哪里放置我的自定义许可证密钥。
我有多个端点,所以我希望我的许可证密钥只有一个地方。从代码中设置它会更好。
谢谢