【问题标题】:In wso2 identity server 5.9.0 is it possible to restrict an SP authentication to a single user store?在 wso2 身份服务器 5.9.0 中,是否可以将 SP 身份验证限制为单个用户存储?
【发布时间】:2020-06-08 18:50:13
【问题描述】:

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

【问题讨论】:

    标签: wso2 wso2is


    【解决方案1】:

    您也可以使用 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.'});
                }
            }
        });
    };
    

    【讨论】:

    • 您好 Senthalan,我看过您提到的文档,但不确定是否必须执行至少 2 个步骤。谢谢。将尝试并发布它的进展情况。这是将 SP authn 限制为用户存储的唯一选择吗? wso2is 中的 authn 是否总是查看所有用户存储?如果我添加更多 SP,我是否需要启用多租户并添加新租户,或者我当前(和您建议的)方法是否足够(添加新 SP 并根据要求并使用自适应身份验证来限制一个或多个用户商店)?对 wso2is 租户、域、用户商店等文档的任何参考将不胜感激。
    • 嗨 Senthalan,我无法让代码工作。只是为了检查自适应 authn 是否确实发生了,我把下面的代码改为但仍然 authn 成功。你能告诉我我可能做错了什么吗? var onLoginRequest = function(context) { executeStep(1, { onSuccess: function (context) { sendError('http://aaa.bbb.com',{'errorcode':'000999','errorMsg':'You are not allowed to login to this app.'}); } }); };
    • 嗨 Senthalan,对不起,我正在使用 curl 和密码授权类型进行测试,以测试它不断返回访问代码(SP 设置的一些问题)。通过 SP 测试时,我可以看到自适应 authn 脚本生效。现在需要测试这个用例并查看它的工作情况 - 将发布其进度更新。
    • 是的。密码授予流程不会调用自适应或 XAMCL 策略。您需要尝试提示登录页面的流程
    【解决方案2】:

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

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

    下面给出了一个基于用户存储对用户进行身份验证的示例 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>    
    

    【讨论】:

    • 嗨 Piraveena,感谢您的回答,但 ACL 不会仅在身份验证过程本身之后启动,这可能已使用来自任何 wso2is 用户存储的用户凭据成功发生。我想知道身份验证过程本身是否可能仅限于特定的用户存储。如果我不清楚我在问什么,请告诉我,因为这是我第一次使用 wso2is(之前曾在 Oracle OAM 上工作过)。
    • 您是否按照此文档在 SP 级别配置了“启用授权”?并将政策发布给 PDP?
    • 嗨 Piraveena,哦不,我还没有开始尝试你的建议——只是想更好地了解使用 ACL 的用例。您能否为我澄清以下内容 - 我希望用户在使用域/用户存储前缀的情况下针对单个用户存储进行身份验证 - 如果相同的用户名(和密码)出现在 2 个用户中商店和第一个(不知道 wso2is 遵循什么顺序)用于成功验证用户,而第二个是 ACL 唯一允许的,用户永远无法登录吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    相关资源
    最近更新 更多