-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#5790] auth(chain): Chain authorization properties #5791
Conversation
Kindly note that this PR should reference fix:5790, not fix:5779. |
@orenccl Thank you for your help check it. Thanks. |
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMeta.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/AuthorizationPropertiesMeta.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMeta.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMeta.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/AuthorizationPropertiesMeta.java
Outdated
Show resolved
Hide resolved
@mchades I fixed all problems, Please help me review again, thanks! |
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/PropertyEntry.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/PropertyEntry.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/authorization/AuthorizationPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/authorization/AuthorizationPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
@mchades I fixed all the problems, please help me review it again. Thanks. |
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/gravitino/connector/WildcardPropertiesMetadata.java
Outdated
Show resolved
Hide resolved
@mchades I fixed all the problems, please help me review it again. Thanks. |
...r/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationProperties.java
Show resolved
Hide resolved
...-ranger/src/main/java/org/apache/gravitino/authorization/ranger/AuthorizationProperties.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java
Show resolved
Hide resolved
...src/test/java/org/apache/gravitino/connector/authorization/mysql/TestMySQLAuthorization.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/apache/gravitino/connector/authorization/ranger/TestRangerAuthorization.java
Outdated
Show resolved
Hide resolved
...-ranger/src/main/java/org/apache/gravitino/authorization/ranger/AuthorizationProperties.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java
Show resolved
Hide resolved
} | ||
} | ||
|
||
resultProperties.forEach((key, value) -> System.out.println(key + " = " + value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz remove the println
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
* "authorization.chain.hive1.ranger.password" = "admin"; <br> | ||
* "authorization.chain.hive1.ranger.service.name" = "hiveDev"; <br> | ||
* "authorization.chain.hdfs1.provider" = "ranger"; <br> | ||
* "authorization.chain.hdfs1.catalog-provider" = "hadoop"; <br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't reasonable. The plugins of the chain should have the same catalog provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
@@ -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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadoop SQL is more suitable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NPE when properties.get(CHAIN_PLUGINS_PROPERTIES_KEY)
return null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
|
||
String[] pluginNames = properties.get(CHAIN_PLUGINS_PROPERTIES_KEY).split(PLUGINS_SPLITTER); | ||
Preconditions.checkArgument( | ||
pluginNames.length > 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant check since the below check Arrays.asList(pluginNames).contains(pluginName)
already includes this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
@@ -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 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.8.0-incubating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
...er/src/main/java/org/apache/gravitino/authorization/ranger/ChainAuthorizationProperties.java
Show resolved
Hide resolved
Arrays.asList(pluginNames).contains(pluginName), | ||
String.format("pluginName %s must be one of %s", pluginName, Arrays.toString(pluginNames))); | ||
|
||
String regex = "^authorization\\.chain\\.(" + pluginName + ")\\..*"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitate about regex expression. Usually regex expression will make code hard to understand. Is it neccessary although the regex epression seems simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to use regular expressions:
- Check whether the plugin name meets requirements. For example, the plugin name cannot be included
.
symbol. - Check that the plugin name must be one of several values specified
- 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can get the configuration by configuration prefix like authorization.pluginName.xxxx
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChainAuthorizationProperties is just a regular expression.
"authorization.chain.plugins" = "hive1,hdfs1" <br>
"authorization.chain.*.provider" = "ranger"; <br>
"authorization.chain.*.ranger.service.type" = "HadoopSQL"; <br>
"authorization.chain.*.ranger.service.name" = "hiveDev"; <br>
"authorization.chain.*.ranger.auth.type" = "simple"; <br>
"authorization.chain.*.ranger.admin.url" = "http://localhost:6080"; <br>
"authorization.chain.*.ranger.username" = "admin"; <br>
"authorization.chain.*.ranger.password" = "admin"; <br>
We can use ChainAuthorizationProperties
to configuration multiple plugin properties.:
Configuration Example: <br>
"authorization.chain.plugins" = "hive1,hdfs1" <br>
"authorization.chain.hive1.provider" = "ranger"; <br>
"authorization.chain.hive1.ranger.service.type" = "HadoopSQL"; <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" = "HDFS"; <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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion, I still think prefix match is better than regex expression. But I think we don't need to block the pull request because of this point.
We can strictly check user properties configurations in the chain by using regular. |
What changes were proposed in this pull request?
Why are the changes needed?
Fix: #5790
Does this PR introduce any user-facing change?
N/A
How was this patch tested?
Add test