【问题标题】:unable to see the custom attribute finder in wso2 IS as KM 5.10.0无法在 wso2 IS 中看到自定义属性查找器为 KM 5.10.0
【发布时间】:2020-09-22 08:00:36
【问题描述】:

您好,我正在使用 wso2 IS 作为 APIM 3.1.0 的 KM。

我想在 wso2 ID 服务器中创建自定义属性查找器。我跟着这个链接 https://is.docs.wso2.com/en/5.9.0/develop/writing-a-custom-policy-info-point/

但最后我无法在 PDP 扩展视图下的 wso2 ID 服务器中看到自定义属性查找器。

我在 entitlement.properties 中包含以下数据源

DataSourceName=jdbc/testuserstore

KmarketJDBCAttributeFinder 中的 Init 方法如下所示:

@Override
    public void init(Properties properties)  throws Exception{

        String dataSourceName = (String) properties.get("DataSourceName");

        if(dataSourceName == null || dataSourceName.trim().length() == 0){
            throw new Exception("Data source name can not be null. Please configure it in the entitlement.properties file.");
        }

        dataSource = (DataSource) InitialContext.doLookup(dataSourceName);
        ................
        ...............

我在 deployment.toml 文件中包含以下配置

[server]
hostname = "10.57.8.4"
node_ip = "10.57.8.4"
base_path = "https://$ref{server.hostname}:${carbon.management.port}"
serverDetails = "WSO2 IS as KM 5.10.0"
mode = "single"
userAgent = "WSO2 IS as KM 5.10.0"

[super_admin]
username = "admin"
password = "admin"
create_admin_account = true

[user_store]
type = "database_unique_id"

[database.apim_db]
type = "postgre"
url = "jdbc:postgresql://10.57.8.45:5432/wso2apimdb"
username = "wso2apim"
password = "password"
driver = "org.postgresql.Driver"
validationQuery = "SELECT 1"

[database.shared_db]
type = "postgre"
url = "jdbc:postgresql://10.57.8.45:5432/wso2shareddb"
username = "wso2shared"
password = "password"
driver = "org.postgresql.Driver"
validationQuery = "SELECT 1"


[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
service_url = "https://10.57.8.46:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"

[keystore.primary]
file_name = "idserver.jks"
password = "password"
alias = "idserver"
key_password = "password"

[admin_service.wsdl]
enable= true

[[datasource]]
id = "testuserstore"
#type = "postgre"
url = "jdbc:postgresql://10.57.8.45:5432/testuserstore"
username = "testuser"
password = "password"
#driver = "org.postgresql.Driver"
#validationQuery = "SELECT 1"


[[xacml.pip.attribute_designator]]
class = "org.xacmlinfo.xacml.pip.jdbc.KMarketJDBCAttributeFinder"
[xacml.pip.attribute_designator.properties]
DataSourceName = "jdbc/testuserstore"


[[event_listener]]
id = "mutual_tls_authenticator"
type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
name = "org.wso2.carbon.identity.oauth2.token.handler.clientauth.mutualtls.MutualTLSClientAuthenticator"
order = "158"
enable = false

[[apim.throttling.url_group]]
traffic_manager_urls=["tcp://10.57.8.46:9611"]
traffic_manager_auth_urls=["ssl://10.57.8.46:9711"]
type = "loadbalance"

testuserstore 是在 postgresql DB 中创建的数据库。如链接中所述,我已经在数据库中创建了表。还将 postgres jdbc 驱动程序和 org.xacmlinfo.xacml.pip.jdbc-1.0.0.jar 包含在 /repository/components/lib 中。我正在使用 jdk 8 来构建 jar 文件。

请告诉我问题出在哪里。

【问题讨论】:

    标签: wso2 wso2is


    【解决方案1】:

    您可以使用以下配置注册自定义属性查找器。

    [identity.entitlement.policy_point.pip]
    attribute_designators = [
      "org.wso2.carbon.identity.entitlement.pip.DefaultAttributeFinder",
      "org.wso2.carbon.identity.application.authz.xacml.pip.AuthenticationContextAttributePIP",
      "org.xacmlinfo.xacml.pip.jdbc.KMarketJDBCAttributeFinder"
    ]
    

    针对产品文档提出public jira 以相应地更新文档。

    所需的数据源应定义为自定义属性查找器的属性。由于产品的明确限制,扩展包名称应采用以下格式, org.wso2.carbon.identity.entitlement.{{extension.name}}。这是在https://github.com/wso2/product-is/issues/8450. 中跟踪的

    作为获得示例工作的解决方法,您可以按照以下方式之一进行操作。不建议使用选项 2,因为不应修改配置模板文件。

    选项 1:

    1. 将示例的包更改为org.wso2.carbon.identity.entitlement.KMarketJDBCAttributeFinder
    2. deployment.toml 中的配置如下。
    [identity.entitlement.policy_point.pip]
    attribute_designators = [
      "org.wso2.carbon.identity.entitlement.pip.DefaultAttributeFinder",
      "org.wso2.carbon.identity.application.authz.xacml.pip.AuthenticationContextAttributePIP",
      "org.wso2.carbon.identity.entitlement.KMarketJDBCAttributeFinder"
    ]
    [[identity.entitlement.extension]]
    name="KMarketJDBCAttributeFinder"
    [identity.entitlement.extension.properties]
    DataSourceName = "jdbc/KMARKETUSERDB"
    

    选项 2: 通过这种方式,您可以将任何包名称作为自定义属性查找器。

    1. 编辑 /repository/resources/conf/templates/repository/conf/identity 目录中的 entitlement.properties.j2 文件。
    2. 搜索 identity.entitlement.extension 并按如下方式更改模板化配置。
    {% if identity.entitlement.extension is defined %}
    {% for extension in identity.entitlement.extension %}
    {% for key,value in extension.properties.items() %}
    {{extension.name}}.{{loop.index}}={{key}},{{value}}
    {% endfor %}
    {% endfor %}
    {% endif %}
    
    1. deployment.toml 中的配置如下。
    [identity.entitlement.policy_point.pip]
    attribute_designators = [
      "org.wso2.carbon.identity.entitlement.pip.DefaultAttributeFinder",
      "org.wso2.carbon.identity.application.authz.xacml.pip.AuthenticationContextAttributePIP",
      "org.xacmlinfo.xacml.pip.jdbc.KMarketJDBCAttributeFinder"
    ]
    [[identity.entitlement.extension]]
    name="org.xacmlinfo.xacml.pip.jdbc.KMarketJDBCAttributeFinder"
    [identity.entitlement.extension.properties]
    DataSourceName = "jdbc/KMARKETUSERDB"
    

    谢谢

    【讨论】:

    • 如果还没有虹吸(用于测试),是否需要指定数据源? /repository/components/lib 中的扩展 jar 文件是否有命名约定?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2017-07-24
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多