gpt4 book ai didi

WCF/WIF - 我应该在后端找到 claim 吗?

转载 作者:行者123 更新时间:2023-12-04 14:02:05 25 4
gpt4 key购买 nike

我有一个调用 WCF 服务的 ASP.NET 应用程序。
在 ASP.NET 应用程序中,我调用 ADFS 来执行身份验证,我可以在 CurrentPrincipal 中看到用户的所有声明。然后我执行了 WCF 服务(wsHttpBinding)的调用,但是声明列表是空的。

可能是什么原因?

最佳答案

如果我没记错的话,在 WCF 中可以通过不同的方式获得 Claims。

Thread.CurrentPrincipal - 简单易用,但需要在您的配置中进行一些设置,这是最容易被忽视的。

<behaviors>
<serviceBehaviors>
<behavior name="Test.Services.WifBehavior">
<serviceCredentials useIdentityConfiguration="true" />
<!---Set principalPermissionMode to always to pass the ClaimsIdentity info to the Thread.CurrentPrincipal-->
<serviceAuthorization principalPermissionMode="Always"/>
</behavior>
<serviceBehaviors>
</behaviors>

OperationContext.Current.ClaimsPrincipal - 我不记得这是否需要一些配置,但我想你可以直接从调用的方法中获取它。

OperationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets - Create a Custom Authorization Manager for a Service并且需要在配置中添加。

请注意,我使用了 Windows Identity Foundation (WIF)。

关于WCF/WIF - 我应该在后端找到 claim 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33668577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com