如何在IS 5.9.0中实现一个服务提供商只使用一个用户存储区进行身份验证?



我使用的是WSO2身份服务器5.9.0。我已经创建了3个用户存储和许多服务提供商。

我正在使用XACML策略,以便允许每个服务提供者只接受一个用户存储中存在的发送请求的用户。策略是下一个:

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyId="POLICY-NAME" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" Version="1.0">
<Description>I wirte a description</Description>
<Target>
<AnyOf>
<AllOf>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">scope_validation</AttributeValue>
<AttributeDesignator AttributeId="http://wso2.org/identity/identity-action/action-name" Category="http://wso2.org/identity/identity-action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Match>
<Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ServiceProviderNameHere</AttributeValue>
<AttributeDesignator AttributeId="http://wso2.org/identity/sp/sp-name" Category="http://wso2.org/identity/sp" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Match>
</AllOf>
</AnyOf>
</Target>
<Rule Effect="Permit" RuleId="permit_by_userstores">
<Condition>
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-one-and-only">
<AttributeDesignator AttributeId="http://wso2.org/identity/user/user-store-domain" Category="http://wso2.org/identity/user" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
</Apply>
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">USER-STORE-NAME</AttributeValue>
</Apply>
</Condition>
</Rule>
<Rule Effect="Deny" RuleId="deny_others"></Rule>
</Policy> 

我发现的问题是,用户正在所有用户存储中查找(一对一),当它找到用户时,停止搜索并将用户存储与策略中的用户存储进行比较。如果两个用户存储名相等,则工作正常。但是,如果我有两个用户存储相同的用户,并且身份服务器首先在用户存储中找到了策略不允许的用户,则返回一个错误,并且它不会继续查找。

我如何做到一个服务提供者只使用一个用户存储进行身份验证?

还有别的方法吗?

谢谢。

您的需求可以通过WSO2-IS 5.9.0以来提供的用户存储首选顺序特性来满足。它允许你定义只有特定的用户存储,用户可以访问特定的服务提供者,或者用户存储链的顺序应该被检查。

参考这个定制示例:https://anuradha-15.medium.com/how-to-configure-your-preferred-user-stores-to-authenticate-users-for-a-service-provider-in-wso2-cdadf43f9366

功能:https://github.com/wso2/product-is/issues/4350

最新更新