首页 文章

使用WSO2 API Manager在WSO2 Identity Server中的策略权利XACML

提问于
浏览
0

我有一个要求,我已经将WSO2身份服务器(5.3)内部LDAP与WSO2 API Manager(2.1)集成在一起 .

我通过取消注释以下代码取消注释wso2-api-2.1 \ repository \ conf \ user-mgt.xml中的LDAP配置来完成更改 .

<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager">
and commented the below.
<UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">

我按照WAC2文档中提到的使用XACML进行基于角色的访问控制的所有步骤,如下所示 . https://docs.wso2.com/display/AM210/Enabling+Role-Based+Access+Control+Using+XACML

我创建了一个角色'schooladmin'和一个用户'testuser' . 我在Identity Server中将角色'chooladmin'分配给'testuser'以及授予的所有权限 .

我能够在WSO2身份存储中测试PDP,它运行正常 .

问题:

  • 由于Identity Server和API Manager通过LDAP连接,我无法在API Manager中看到Identity Server中开发的PDP . 这是正确的行为吗?

  • 我创建并部署了REST API基础的业务服务,并在配置期间添加了权利元素,如WSO2文档中所述 .

<sequence xmlns="http://ws.apache.org/ns/synapse"  name="newEntitlementMediator"> 
                <entitlementService xmlns="http://ws.apache.org/ns/synapse" remoteServiceUrl="https://localhost:9443/services" remoteServiceUserName="admin" remoteServicePassword="admin" 
                callbackClass="org.wso2.sample.handlers.entitlement.APIEntitlementCallbackHandler"/>
                </sequence>

当我在Postman中尝试新开发的REST API时,我总是得到以下错误 .

<am:fault xmlns:am="http://wso2.org/apimanager">
    <am:code>0</am:code>
    <am:type>Status report</am:type>
    <am:message>Runtime Error</am:message>
    <am:description>User is not authorized to perform the action</am:description>
</am:fault>

为了测试,我正在使用提供的以下服务创建具有正确用户'testuser'的新令牌 - https://localhost:8244/token

请建议是否有任何限制或我错过任何配置 .

我正在添加在WSO2 IS服务器中创建的策略以获取权利 . 请查阅 .

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="iib_policy_entitlement" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit" Version="1.0">
   <Target/>
   <Rule Effect="Permit" RuleId="iib_test_rule">
      <Target>
         <AnyOf>
            <AllOf>
               <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/login/v1</AttributeValue>
                  <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
               </Match>
               <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">POST</AttributeValue>
                  <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
               </Match>
            </AllOf>
         </AnyOf>
      </Target>
      <Condition>
         <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
               <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">iib_role</AttributeValue>
            </Apply>
            <AttributeDesignator AttributeId="http://wso2.org/claims/role" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/>
         </Apply>
      </Condition>
   </Rule>
</Policy>

谢谢,Abhishek

1 回答

  • 0

    问题1的答案:是的,LDAP仅用作用户存储 . 元数据存储在单独的数据库中 . 如果您还需要共享元数据,那么您也共享元数据DB . 请更改/repository/conf/datasourses/master-datasourses.xml .

    对问题2的回答:不能直接回答这个问题,但我可以给你几点检查 .

    • 检查您是否可以从API管理器端看到创建的用户和角色 .

    • 您是否希望IS充当APIM的关键经理?如果是这样,请查看此文档 . IS as a Key Manager

相关问题