简体   繁体   English

如何向ACS服务标识添加声明

[英]How do I add claims to an ACS Service Identity

I'm not even sure that this is possible but I am not able to find a clear answer in any kbs, help or documentation. 我甚至不确定这是可能的,但我无法在任何kbs,帮助或文档中找到明确的答案。

I have a WebAPI which is secured via ACS. 我有一个通过ACS保护的WebAPI。 An application uses a service identity to authenticate via ACS with my WebAPI to allow access. 应用程序使用服务标识通过ACS使用我的WebAPI进行身份验证以允许访问。 What I would like to do is have claims presented for the service identity to identify the individual identities. 我想要做的是提出服务标识的声明,以识别个人身份。 ie Service Identity A presents a type and id for example and Service Identity B presents different values for the same claim types, and then my WebAPI can authorize particular calls based on the claim values. 即服务标识A表示类型和标识,例如,服务标识B为相同的声明类型显示不同的值,然后我的WebAPI可以根据声明值授权特定的调用。

Currently I have this implemented via a Rule Group using Output Claims with Claim Values set via the ACS Portal however the rule group is applied to all service identities accessing the relying application (My WebAPI), what I need is to have the service identities each having differing claim values. 目前,我通过规则组实现了这一点,使用通过ACS门户设置的索赔值的输出声明但是规则组适用于访问依赖应用程序(My WebAPI)的所有服务身份,我需要的是拥有每个服务身份的服务身份不同的索赔价值。

As all communication is service to service I planned on using ACS and not another Identity Provider such as Live/Microsoft Account or Google. 由于所有通信都是服务,我计划使用ACS,而不是其他身份提供商,如Live / Microsoft Account或Google。 However at present the only conclusion I can come to is implementing my own custom STS to provide the Claims Values. 但是目前我唯一可以得出的结论是实现我自己的自定义STS以提供声明值。

I hope I've explained my scenario clearly can anyone help at all, how do I set claim values for individual Service Identities or should I be doing this a different way? 我希望我已经清楚地解释了我的情况,任何人都可以提供帮助,如何为各个服务标识设置声明值,还是应该以不同的方式进行此操作?

Thanks 谢谢

Andrew 安德鲁

IIRC the appplication creates its own tokens and signs them with the cert/symm key - the claims in that token then become inputs in the rules engine... IIRC应用程序创建自己的令牌并使用cert / symm键对其进行签名 - 该令牌中的声明随后成为规则引擎中的输入...

..but it's been a while ;) ..但它已经有一段时间;)

I managed to resolve this just before I left the office for the Christmas/New Year break and wanted to note how I resolved the issue for anyone else who might find it useful. 在我离开办公室过圣诞节/新年假期之前,我设法解决了这个问题,并想知道我是如何为其他可能发现有用的人解决问题的。

I stepped back from the problem and came back to it with a fresh view. 我退出了问题并以新的视角回到了它。 As my application authenticates based on service identity and the authentication is between a service calling my service(s) there will not be a large number of service identities to authenticate against. 由于我的应用程序基于服务标识进行身份验证,并且身份验证是在调用我的服务的服务之间进行身份验证,因此不会有大量的服务标识进行身份验证。 Therefore for my requirements I am able to utilise rule groups to provide claims based on a supplied claim. 因此,根据我的要求,我可以利用规则组根据提供的索赔提供索赔。

All of my Windows Azure Access Control Service Identities present a nameidentifier claim ( http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name identifier) and so for each new Service Identity I have created a new Rule Group in the ACS Portal: 我的所有Windows Azure访问控制服务标识都提供了nameidentifier声明( http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name标识符),因此对于每个新的服务标识,我创建了一个新规则ACS门户组:

创建新的ACS规则组

Once this new Rule Group is created I chose to add a Rule as below. 创建此新规则组后,我选择添加规则,如下所示。 I have selected that the InputClaim Issuer is the Access Control Service as the ACS is supplying the token to authenticate with my service. 我选择了InputClaim Issuer是访问控制服务,因为ACS正在提供令牌以通过我的服务进行身份验证。 Next a select the input claim type I am expecting to receive and which I am checking for in my If statement. 接下来选择我期望接收的输入声明类型以及我在If语句中检查的输入声明类型。 Therefore in the example below, if the nameidentifier claim provided has a value of StackOverflow (The name of the Service Identity I am expecting) then I wish to return the Country output claim with a value of UK with the token returned by ACS. 因此,在下面的示例中,如果提供的nameidentifier声明具有StackOverflow值(我期望的服务标识的名称),那么我希望返回带有ACS返回的令牌的UK输出声明。 I have also added additional rules to add further output claims where equired. 我还添加了额外的规则,以便在需要的地方添加更多输出声明。 This allowed me to return the correct claims and values for the corresponding service identities. 这允许我返回相应服务标识的正确声明和值。

添加ACS声明规则

Finally I went to my list of Relying Party Applications and selected my relying party application (my service) and selected the new Rule Group I had created. 最后,我进入了依赖方应用程序列表并选择了我的依赖方应用程序(我的服务)并选择了我创建的新规则组。

选择依赖方申请的规则组

This approach has resolved my issue and has enabled me to now read the claims from the token provided to my rest service and make decisions based on the values provided. 这种方法解决了我的问题,使我现在可以从提供给我的休息服务的令牌中读取声明,并根据提供的值做出决定。 I'd started out looking for a much more complicated approach and found when I stepped back and looked at the requirement clearly I was able to achieve my requirement with core ACS functionality. 我开始寻找一种更复杂的方法,当我退后一步看清楚要求时,我能够通过核心ACS功能实现我的要求。 Hope this helps someone else with similar requirements. 希望这有助于其他有类似要求的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM