在wso2身份服务器5.9.0中,是否可以将SP身份验证限制为单个用户存储?

时间:2020-02-25 05:04:50

标签: wso2 wso2is

我在带有jdk 11.0.6的OEL 7.6上安装了wso2身份服务器5.9.0。我已经为基于OpenID Connect的身份验证配置了一个SP-客户端是Oracle HTTP Server,具有对weblogic服务器上的应用程序的mod_auth_oidc代理请求。我已经为SP的用户专门创建了一个辅助用户存储,我想仅使用该辅助用户存储(不使用登录名的域前缀)限制SP身份验证,但是无法找到专门用于该用户的任何选项/信息那。我还将为其他SP应用程序提供更多的辅助用户存储,并且它们可能具有使用相同用户名的用户。我看过一篇有关使用XACML来实现用户存储或角色受限授权策略的文章-这是针对此类要求的推荐方法,还是有另一种更简单/更好的方法来实现这一要求?

2 个答案:

答案 0 :(得分:0)

您也可以使用XACML策略。但是在5.9.0中,您可以使用自适应身份验证script来控制对特定用户存储的访问。

如果用户来自特定的用户商店,则上述链接的方案将加紧执行。就您而言,如果用户来自其他用户商店,则不需要使用sendError功能。

这是一个示例脚本

var allowedUserstores = ['EMPLOYEES', 'CONTRACTORS'];

var onLoginRequest = function(context) {
    executeStep(1, {
        onSuccess: function (context) {
            // Extracting user store domain of authenticated subject from the first step
            var userStoreDomain = context.currentKnownSubject.userStoreDomain;
            if (userStoresToStepUp.indexOf(userStoreDomain) < 0) {
                sendError('http://www.example.com/error',{'errorcode':'000403','errorMsg':'You are not allowed to login to this app.'});
            }
        }
    });
};

答案 1 :(得分:0)

您可以使用XACML进行细粒度的访问控制。对于身份验证流程,

  • 通过管理控制台发布XACML策略,该策略可以验证用户属性和用户存储并返回是否可以对用户进行身份验证以访问资源。
  • 您可以按照此documentation来配置服务提供商的访问控制策略。

下面给出了一个基于userstore对用户进行身份验证的示例XACML策略

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"  PolicyId="authn_dynamic_userstore_based_policy_template" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" Version="1.0">
   <Description>This policy template provides ability to authorize users to a given service provider(defined by SP_NAME) in the authentication flow based on the userstore of the user. Users who are in the userstore,will be allowed any others will be denied.</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">travelocity.com</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="false"></AttributeDesignator>
            </Match>
            <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">authenticate</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="false"></AttributeDesignator>
            </Match>
         </AllOf>
      </AnyOf>
   </Target>
   <Rule Effect="Permit" RuleId="permit_by_userstore">
      <Condition>
         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">PRIMARY</AttributeValue>
               <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>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">carbon.super</AttributeValue>
               <AttributeDesignator AttributeId="http://wso2.org/identity/user/user-tenant-domain" Category="http://wso2.org/identity/user" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
            </Apply>
         </Apply>
      </Condition>
   </Rule>
   <Rule Effect="Deny" RuleId="deny_others"></Rule>
</Policy>    
相关问题