xunliu commented on code in PR #5791: URL: https://github.com/apache/gravitino/pull/5791#discussion_r1887870879
########## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.authorization.ranger; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * The properties for Chain authorization plugin. <br> + * <br> + * Configuration Example: <br> + * "authorization.chain.plugins" = "hive1,hdfs1" <br> + * "authorization.chain.hive1.provider" = "ranger"; <br> + * "authorization.chain.hive1.ranger.service.type" = "hive"; <br> + * "authorization.chain.hive1.ranger.service.name" = "hiveDev"; <br> + * "authorization.chain.hive1.ranger.auth.type" = "simple"; <br> + * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080"; <br> + * "authorization.chain.hive1.ranger.username" = "admin"; <br> + * "authorization.chain.hive1.ranger.password" = "admin"; <br> + * "authorization.chain.hdfs1.provider" = "ranger"; <br> + * "authorization.chain.hdfs1.ranger.service.type" = "hadoop"; <br> + * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev"; <br> + * "authorization.chain.hdfs1.ranger.auth.type" = "simple"; <br> + * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080"; <br> + * "authorization.chain.hdfs1.ranger.username" = "admin"; <br> + * "authorization.chain.hdfs1.ranger.password" = "admin"; <br> + */ +public class ChainAuthorizationProperties { + public static final String PLUGINS_SPLITTER = ","; + /** Chain authorization plugin names */ + public static final String CHAIN_PLUGINS_PROPERTIES_KEY = "authorization.chain.plugins"; + + /** Chain authorization plugin provider */ + public static final String CHAIN_PROVIDER = "authorization.chain.*.provider"; + + static Map<String, String> fetchAuthPluginProperties( + String pluginName, Map<String, String> properties) { + Preconditions.checkArgument( + properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY), + String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY)); + + String[] pluginNames = properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER); + Preconditions.checkArgument( + pluginNames.length > 0, Review Comment: DONE ########## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ########## @@ -34,28 +34,25 @@ * Configuration Example: <br> * "authorization.chain.plugins" = "hive1,hdfs1" <br> * "authorization.chain.hive1.provider" = "ranger"; <br> - * "authorization.chain.hive1.catalog-provider" = "hive"; <br> + * "authorization.chain.hive1.ranger.service.type" = "hive"; <br> Review Comment: DONE ########## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.authorization.ranger; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * The properties for Chain authorization plugin. <br> + * <br> + * Configuration Example: <br> + * "authorization.chain.plugins" = "hive1,hdfs1" <br> + * "authorization.chain.hive1.provider" = "ranger"; <br> + * "authorization.chain.hive1.ranger.service.type" = "hive"; <br> + * "authorization.chain.hive1.ranger.service.name" = "hiveDev"; <br> + * "authorization.chain.hive1.ranger.auth.type" = "simple"; <br> + * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080"; <br> + * "authorization.chain.hive1.ranger.username" = "admin"; <br> + * "authorization.chain.hive1.ranger.password" = "admin"; <br> + * "authorization.chain.hdfs1.provider" = "ranger"; <br> + * "authorization.chain.hdfs1.ranger.service.type" = "hadoop"; <br> + * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev"; <br> + * "authorization.chain.hdfs1.ranger.auth.type" = "simple"; <br> + * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080"; <br> + * "authorization.chain.hdfs1.ranger.username" = "admin"; <br> + * "authorization.chain.hdfs1.ranger.password" = "admin"; <br> + */ +public class ChainAuthorizationProperties { + public static final String PLUGINS_SPLITTER = ","; + /** Chain authorization plugin names */ + public static final String CHAIN_PLUGINS_PROPERTIES_KEY = "authorization.chain.plugins"; + + /** Chain authorization plugin provider */ + public static final String CHAIN_PROVIDER = "authorization.chain.*.provider"; + + static Map<String, String> fetchAuthPluginProperties( + String pluginName, Map<String, String> properties) { + Preconditions.checkArgument( + properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY), + String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY)); + + String[] pluginNames = properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER); Review Comment: DONE ########## docs/security/authorization-pushdown.md: ########## @@ -24,7 +24,8 @@ In order to use the Ranger Hadoop SQL Plugin, you need to configure the followin | `authorization.ranger.auth.type` | The Apache Ranger authentication type `simple` or `kerberos`. | `simple` | No | 0.6.0-incubating | | `authorization.ranger.username` | The Apache Ranger admin web login username (auth type=simple), or kerberos principal(auth type=kerberos), Need have Ranger administrator permission. | (none) | No | 0.6.0-incubating | | `authorization.ranger.password` | The Apache Ranger admin web login user password (auth type=simple), or path of the keytab file(auth type=kerberos) | (none) | No | 0.6.0-incubating | -| `authorization.ranger.service.name` | The Apache Ranger service name. | (none) | No | 0.6.0-incubating | +| `authorization.ranger.service.type` | The Apache Ranger service type. | (none) | No | 0.6.0-incubating | Review Comment: DONE -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org