Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu merged PR #5791: URL: https://github.com/apache/gravitino/pull/5791 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on PR #5791: URL: https://github.com/apache/gravitino/pull/5791#issuecomment-2547772489 We can strictly check user properties configurations in the chain by using regular. Checking with strings is less elegant. Can I reference in `TestChainAuthorizationProperties.java` Some test cases in Java. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888061668
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "HDFS";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY)
+&& properties.get(CHAIN_PLUGINS_PROPERTIES_KEY) != null,
+String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String[] pluginNames =
properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER);
+Preconditions.checkArgument(
+Arrays.asList(pluginNames).contains(pluginName),
+String.format("pluginName %s must be one of %s", pluginName,
Arrays.toString(pluginNames)));
+
+String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*";
Review Comment:
ChainAuthorizationProperties is just a regular expression.
```
"authorization.chain.plugins" = "hive1,hdfs1"
"authorization.chain.*.provider" = "ranger";
"authorization.chain.*.ranger.service.type" = "HadoopSQL";
"authorization.chain.*.ranger.service.name" = "hiveDev";
"authorization.chain.*.ranger.auth.type" = "simple";
"authorization.chain.*.ranger.admin.url" = "http://localhost:6080";;
"authorization.chain.*.ranger.username" = "admin";
"authorization.chain.*.ranger.password" = "admin";
```
We can use `ChainAuthorizationProperties` to configuration multiple plugin
properties.:
```
Configuration Example:
"authorization.chain.plugins" = "hive1,hdfs1"
"authorization.chain.hive1.provider" = "ranger";
"authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
"authorization.chain.hive1.ranger.service.name" = "hiveDev";
"authorization.chain.hive1.ranger.auth.type" = "simple";
"authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
"authorization.chain.hive1.ranger.username" = "admin";
"authorization.chain.hive1.ranger.password" = "admin";
"authorization.chain.hdfs1.provider" = "ranger";
"authorization.chain.hdfs1.ranger.service.type" = "HDFS";
"authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
"authorization.chain.hdfs1.ranger.auth.type" = "simple";
"authorizatio
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888061668
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "HDFS";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY)
+&& properties.get(CHAIN_PLUGINS_PROPERTIES_KEY) != null,
+String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String[] pluginNames =
properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER);
+Preconditions.checkArgument(
+Arrays.asList(pluginNames).contains(pluginName),
+String.format("pluginName %s must be one of %s", pluginName,
Arrays.toString(pluginNames)));
+
+String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*";
Review Comment:
ChainAuthorizationProperties is just a regular expression.
```
"authorization.chain.plugins" = "hive1,hdfs1"
"authorization.chain.*.provider" = "ranger";
"authorization.chain.*.ranger.service.type" = "HadoopSQL";
"authorization.chain.*.ranger.service.name" = "hiveDev";
"authorization.chain.*.ranger.auth.type" = "simple";
"authorization.chain.*.ranger.admin.url" = "http://localhost:6080";;
"authorization.chain.*.ranger.username" = "admin";
"authorization.chain.*.ranger.password" = "admin";
```
We can use `ChainAuthorizationProperties` to configuration multiple plugin
properties.:
```
Configuration Example:
"authorization.chain.plugins" = "hive1,hdfs1"
"authorization.chain.hive1.provider" = "ranger";
"authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
"authorization.chain.hive1.ranger.service.name" = "hiveDev";
"authorization.chain.hive1.ranger.auth.type" = "simple";
"authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
"authorization.chain.hive1.ranger.username" = "admin";
"authorization.chain.hive1.ranger.password" = "admin";
"authorization.chain.hdfs1.provider" = "ranger";
"authorization.chain.hdfs1.ranger.service.type" = "HDFS";
"authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
"authorization.chain.hdfs1.ranger.auth.type" = "simple";
"authorizati
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
jerqi commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888055125
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "HDFS";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY)
+&& properties.get(CHAIN_PLUGINS_PROPERTIES_KEY) != null,
+String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String[] pluginNames =
properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER);
+Preconditions.checkArgument(
+Arrays.asList(pluginNames).contains(pluginName),
+String.format("pluginName %s must be one of %s", pluginName,
Arrays.toString(pluginNames)));
+
+String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*";
Review Comment:
Maybe we can get the configuration by configuration prefix like
`authorization.pluginName.`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791: URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888035438 ## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ## @@ -0,0 +1,160 @@ +/* + * 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. + * + * Configuration Example: + * "authorization.chain.plugins" = "hive1,hdfs1" + * "authorization.chain.hive1.provider" = "ranger"; + * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL"; + * "authorization.chain.hive1.ranger.service.name" = "hiveDev"; + * "authorization.chain.hive1.ranger.auth.type" = "simple"; + * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";; + * "authorization.chain.hive1.ranger.username" = "admin"; + * "authorization.chain.hive1.ranger.password" = "admin"; Review Comment: This case didn't have a relation to this PR, this PR only provided Chain's properties configuration. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888025872
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.catalog-provider" = "hive";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.catalog-provider" = "hadoop";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ */
+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_CATALOG_PROVIDER =
"authorization.chain.*.catalog-provider";
+
+ /** Chain authorization plugin provider */
+ public static final String CHAIN_PROVIDER = "authorization.chain.*.provider";
+
+ static Map fetchAuthPluginProperties(
+ String pluginName, Map 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,
+String.format("%s must have at least one plugin name",
CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String regex = "^authorization\\.chain\\.(" + String.join("|",
pluginNames) + ")\\..*";
+Pattern pattern = Pattern.compile(regex);
+
+Map filteredProperties = new HashMap<>();
+for (Map.Entry entry : properties.entrySet()) {
+ Matcher matcher = pattern.matcher(entry.getKey());
+ if (matcher.matches()) {
+filteredProperties.put(entry.getKey(), entry.getValue());
+ }
+}
+
+String removeRegex = "^authorization\\.chain\\.(" + String.join("|",
pluginNames) + ")\\.";
+Pattern removePattern = Pattern.compile(removeRegex);
+
+Map resultProperties = new HashMap<>();
+for (Map.Entry entry : filteredProperties.entrySet()) {
+ Matcher removeMatcher = removePattern.matcher(entry.getKey());
+ if (removeMatcher.find()) {
+resultProperties.put(removeMatcher.replaceFirst("authorization."),
entry.getValue());
+ }
+}
+
+resultProperties.forEach((key, value) -> System.out.println(key + " = " +
value));
Review Comment:
DONE
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,163 @@
+/*
+ * 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,
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888024676
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "HDFS";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY)
+&& properties.get(CHAIN_PLUGINS_PROPERTIES_KEY) != null,
+String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String[] pluginNames =
properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER);
+Preconditions.checkArgument(
+Arrays.asList(pluginNames).contains(pluginName),
+String.format("pluginName %s must be one of %s", pluginName,
Arrays.toString(pluginNames)));
+
+String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*";
Review Comment:
I need to use regular expressions:
1. Check whether the plugin name meets requirements. For example, the plugin
name cannot be included `.` symbol.
2. Check that the plugin name must be one of several values specified
3. Delete plugin name from the chain attribute to generate plugin attribute
configuration.
Only the simplest regular expressions are used here, which I don't think is
a problem.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
jerqi commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1888003809
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "HadoopSQL";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "HDFS";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(CHAIN_PLUGINS_PROPERTIES_KEY)
+&& properties.get(CHAIN_PLUGINS_PROPERTIES_KEY) != null,
+String.format("%s is required", CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String[] pluginNames =
properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER);
+Preconditions.checkArgument(
+Arrays.asList(pluginNames).contains(pluginName),
+String.format("pluginName %s must be one of %s", pluginName,
Arrays.toString(pluginNames)));
+
+String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*";
Review Comment:
I hesitate about regex expression. Usually regex expression will make code
hard to understand. Is it neccessary although the regex epression seems simple.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "hive";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "hadoop";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map 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:
* "authorization.chain.plugins" = "hive1,hdfs1"
* "authorization.chain.hive1.provider" = "ranger";
- * "authorization.chain.hive1.catalog-provider" = "hive";
+ * "authorization.chain.hive1.ranger.service.type" = "hive";
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.ut
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
jerqi commented on code in PR #5791: URL: https://github.com/apache/gravitino/pull/5791#discussion_r1887839500 ## 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: 0.8.0-incubating? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
mchades commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886683315
##
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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "hive";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.ranger.service.type" = "hadoop";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ */
+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 fetchAuthPluginProperties(
+ String pluginName, Map 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:
Potential NPE when `properties.get(CHAIN_PLUGINS_PROPERTIES_KEY)` return null
##
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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.ranger.service.type" = "hive";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "auth
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
jerqi commented on code in PR #5791: URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886665778 ## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ## @@ -34,28 +34,25 @@ * Configuration Example: * "authorization.chain.plugins" = "hive1,hdfs1" * "authorization.chain.hive1.provider" = "ranger"; - * "authorization.chain.hive1.catalog-provider" = "hive"; + * "authorization.chain.hive1.ranger.service.type" = "hive"; Review Comment: Hadoop SQL is more suitable? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
jerqi commented on code in PR #5791: URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886446331 ## authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java: ## @@ -0,0 +1,163 @@ +/* + * 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. + * + * Configuration Example: + * "authorization.chain.plugins" = "hive1,hdfs1" + * "authorization.chain.hive1.provider" = "ranger"; + * "authorization.chain.hive1.catalog-provider" = "hive"; + * "authorization.chain.hive1.ranger.auth.type" = "simple"; + * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";; + * "authorization.chain.hive1.ranger.username" = "admin"; + * "authorization.chain.hive1.ranger.password" = "admin"; + * "authorization.chain.hive1.ranger.service.name" = "hiveDev"; + * "authorization.chain.hdfs1.provider" = "ranger"; + * "authorization.chain.hdfs1.catalog-provider" = "hadoop"; Review Comment: This isn't reasonable. The plugins of the chain should have the same catalog provider. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
mchades commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886494426
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.catalog-provider" = "hive";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.catalog-provider" = "hadoop";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ */
+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_CATALOG_PROVIDER =
"authorization.chain.*.catalog-provider";
+
+ /** Chain authorization plugin provider */
+ public static final String CHAIN_PROVIDER = "authorization.chain.*.provider";
+
+ static Map fetchAuthPluginProperties(
+ String pluginName, Map 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,
+String.format("%s must have at least one plugin name",
CHAIN_PLUGINS_PROPERTIES_KEY));
+
+String regex = "^authorization\\.chain\\.(" + String.join("|",
pluginNames) + ")\\..*";
+Pattern pattern = Pattern.compile(regex);
+
+Map filteredProperties = new HashMap<>();
+for (Map.Entry entry : properties.entrySet()) {
+ Matcher matcher = pattern.matcher(entry.getKey());
+ if (matcher.matches()) {
+filteredProperties.put(entry.getKey(), entry.getValue());
+ }
+}
+
+String removeRegex = "^authorization\\.chain\\.(" + String.join("|",
pluginNames) + ")\\.";
+Pattern removePattern = Pattern.compile(removeRegex);
+
+Map resultProperties = new HashMap<>();
+for (Map.Entry entry : filteredProperties.entrySet()) {
+ Matcher removeMatcher = removePattern.matcher(entry.getKey());
+ if (removeMatcher.find()) {
+resultProperties.put(removeMatcher.replaceFirst("authorization."),
entry.getValue());
+ }
+}
+
+resultProperties.forEach((key, value) -> System.out.println(key + " = " +
value));
Review Comment:
plz remove the `println`
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,165 @@
+/*
+ * 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 unde
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886233104
##
core/src/test/java/org/apache/gravitino/connector/authorization/mysql/TestMySQLAuthorization.java:
##
@@ -26,9 +26,11 @@ public class TestMySQLAuthorization extends
BaseAuthorizationhttp://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 java.util.Map;
+
+public class RangerAuthorizationProperties implements AuthorizationProperties {
+ /** Ranger admin web URIs */
+ public static final String RANGER_ADMIN_URL =
"authorization.ranger.admin.url";
+
+ /** Ranger service name */
+ public static final String RANGER_SERVICE_NAME =
"authorization.ranger.service.name";
+
+ /** Ranger authentication type kerberos or simple */
+ public static final String RANGER_AUTH_TYPE =
"authorization.ranger.auth.type";
+
+ /**
+ * Ranger admin web login username(auth_type=simple), or kerberos
principal(auth_type=kerberos)
+ */
+ public static final String RANGER_USERNAME = "authorization.ranger.username";
+
+ /**
+ * Ranger admin web login user password(auth_type=simple), or path of the
keytab
+ * file(auth_type=kerberos)
+ */
+ public static final String RANGER_PASSWORD = "authorization.ranger.password";
+
+ @Override
+ public void validateProperties(Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(RANGER_ADMIN_URL),
+String.format("%s is required", RANGER_ADMIN_URL));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_SERVICE_NAME),
+String.format("%s is required", RANGER_SERVICE_NAME));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_AUTH_TYPE),
+String.format("%s is required", RANGER_AUTH_TYPE));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_USERNAME), String.format("%s is
required", RANGER_USERNAME));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_PASSWORD), String.format("%s is
required", RANGER_PASSWORD));
+Preconditions.checkArgument(
+properties.get(RANGER_ADMIN_URL) != null,
Review Comment:
OK, I fixed it.
##
core/src/test/java/org/apache/gravitino/connector/authorization/ranger/TestRangerAuthorization.java:
##
@@ -26,9 +26,11 @@ public class TestRangerAuthorization extends
BaseAuthorizationhttp://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;
+
+/**
+ * ChainAuthorizationProperties is a class that implements {@link
AuthorizationProperties}
+ * interface.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.catalog-provider" = "hive";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin";
+ * "authorization.chain.hive1.ranger.password" = "admin";
+ * "authorization.chain.hive1.ranger.service.name" = "hiveDev";
+ * "authorization.chain.hdfs1.provider" = "ranger";
+ * "authorization.chain.hdfs1.catalog-provider" = "hadoop";
+ * "authorization.chain.hdfs1.ranger.auth.type" = "simple";
+ * "authorization.chain.hdfs1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hdfs1.ranger.username" = "admin";
+ * "authorization.chain.hdfs1.ranger.password" = "admin";
+ * "authorization.chain.hdfs1.ranger.service.name" = "hdfsDev";
+ */
+public class ChainAuthorizationProperties implements AuthorizationProperties {
+ 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_CATALOG_PROVID
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
mchades commented on code in PR #5791:
URL: https://github.com/apache/gravitino/pull/5791#discussion_r1886083415
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationProperties.java:
##
@@ -0,0 +1,74 @@
+/*
+ * 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 java.util.Map;
+
+public class RangerAuthorizationProperties implements AuthorizationProperties {
+ /** Ranger admin web URIs */
+ public static final String RANGER_ADMIN_URL =
"authorization.ranger.admin.url";
+
+ /** Ranger service name */
+ public static final String RANGER_SERVICE_NAME =
"authorization.ranger.service.name";
+
+ /** Ranger authentication type kerberos or simple */
+ public static final String RANGER_AUTH_TYPE =
"authorization.ranger.auth.type";
+
+ /**
+ * Ranger admin web login username(auth_type=simple), or kerberos
principal(auth_type=kerberos)
+ */
+ public static final String RANGER_USERNAME = "authorization.ranger.username";
+
+ /**
+ * Ranger admin web login user password(auth_type=simple), or path of the
keytab
+ * file(auth_type=kerberos)
+ */
+ public static final String RANGER_PASSWORD = "authorization.ranger.password";
+
+ @Override
+ public void validateProperties(Map properties) {
+Preconditions.checkArgument(
+properties.containsKey(RANGER_ADMIN_URL),
+String.format("%s is required", RANGER_ADMIN_URL));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_SERVICE_NAME),
+String.format("%s is required", RANGER_SERVICE_NAME));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_AUTH_TYPE),
+String.format("%s is required", RANGER_AUTH_TYPE));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_USERNAME), String.format("%s is
required", RANGER_USERNAME));
+Preconditions.checkArgument(
+properties.containsKey(RANGER_PASSWORD), String.format("%s is
required", RANGER_PASSWORD));
+Preconditions.checkArgument(
+properties.get(RANGER_ADMIN_URL) != null,
Review Comment:
Why are some properties validated using `properties.get(key) != null` while
others are using `properties.containsKey(key)`? What is the difference?
##
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java:
##
@@ -0,0 +1,165 @@
+/*
+ * 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;
+
+/**
+ * ChainAuthorizationProperties is a class that implements {@link
AuthorizationProperties}
+ * interface.
+ *
+ * Configuration Example:
+ * "authorization.chain.plugins" = "hive1,hdfs1"
+ * "authorization.chain.hive1.provider" = "ranger";
+ * "authorization.chain.hive1.catalog-provider" = "hive";
+ * "authorization.chain.hive1.ranger.auth.type" = "simple";
+ * "authorization.chain.hive1.ranger.admin.url" = "http://localhost:6080";;
+ * "authorization.chain.hive1.ranger.username" = "admin
Re: [PR] [#5790] auth(chain): Chain authorization properties [gravitino]
xunliu commented on PR #5791: URL: https://github.com/apache/gravitino/pull/5791#issuecomment-2540794567 @tengqm @mchades @yuqi1129 I am refactoring this PR, Please help me review it, Thanks. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
