xunliu commented on code in PR #6575:
URL: https://github.com/apache/gravitino/pull/6575#discussion_r1983206299
##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationPlugin.java:
##########
@@ -959,6 +1004,21 @@ protected void
removePolicyByMetadataObject(AuthorizationMetadataObject authzMet
}
}
+ protected String getConfValue(Map<String, String> conf, String key, String
defaultValue) {
+ if (conf.containsKey(key)) {
+ return conf.get(key);
+ }
+ return defaultValue;
+ }
+
+ protected abstract String getServiceType();
+
+ protected abstract Map<String, String> getServiceConfigs(Map<String, String>
config);
+
+ protected int getPrefixLength() {
+ return prefixLength;
Review Comment:
I think we can remove prefixLength variable.
```
protected int getPrefixLength() {
String.format("%s.",
rangerAuthorizationProperties.getPropertiesPrefix()).length();
}
```
##########
authorizations/authorization-chain/src/test/java/org/apache/gravitino/authorization/chain/integration/test/TestChainedAuthorizationIT.java:
##########
@@ -210,6 +210,37 @@ protected void createCatalog() {
metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, "hive",
"comment", catalogConf);
catalog = metalake.loadCatalog(catalogName);
LOG.info("Catalog created: {}", catalog);
+
+ // Test to create chained authorization plugin automatically
+ Map<String, String> autoProperties = new HashMap<>();
+ autoProperties.put(HiveConstants.METASTORE_URIS, HIVE_METASTORE_URIS);
+ autoProperties.put(IMPERSONATION_ENABLE, "true");
+ autoProperties.put(Catalog.AUTHORIZATION_PROVIDER, "chain");
+
autoProperties.put(ChainedAuthorizationProperties.CHAIN_PLUGINS_PROPERTIES_KEY,
"hive1,hdfs1");
+ autoProperties.put("authorization.chain.hive1.provider", "ranger");
+ autoProperties.put("authorization.chain.hive1.ranger.auth.type",
RangerContainer.authType);
+ autoProperties.put("authorization.chain.hive1.ranger.admin.url",
RangerITEnv.RANGER_ADMIN_URL);
+ autoProperties.put("authorization.chain.hive1.ranger.username",
RangerContainer.rangerUserName);
+ autoProperties.put("authorization.chain.hive1.ranger.password",
RangerContainer.rangerPassword);
+ autoProperties.put("authorization.chain.hive1.ranger.service.type",
"HadoopSQL");
+ autoProperties.put("authorization.chain.hive1.ranger.service.name",
"test899");
+
autoProperties.put("authorization.chain.hive1.ranger.service.create-if-absent",
"true");
+ autoProperties.put("authorization.chain.hdfs1.provider", "ranger");
+ autoProperties.put("authorization.chain.hdfs1.ranger.auth.type",
RangerContainer.authType);
+ autoProperties.put("authorization.chain.hdfs1.ranger.admin.url",
RangerITEnv.RANGER_ADMIN_URL);
+ autoProperties.put("authorization.chain.hdfs1.ranger.username",
RangerContainer.rangerUserName);
+ autoProperties.put("authorization.chain.hdfs1.ranger.password",
RangerContainer.rangerPassword);
+ autoProperties.put("authorization.chain.hdfs1.ranger.service.type",
"HDFS");
+ autoProperties.put("authorization.chain.hdfs1.ranger.service.name",
"test833");
+
autoProperties.put("authorization.chain.hdfs1.ranger.service.create-if-absent",
"true");
+ Catalog catalogTest =
+ metalake.createCatalog("test", Catalog.Type.RELATIONAL, "hive",
"comment", autoProperties);
+ Map<String, String> newProperties = catalogTest.properties();
+ Assertions.assertTrue(
+
newProperties.containsKey("authorization.chain.hdfs1.ranger.service.name"));
+ Assertions.assertTrue(
+
newProperties.containsKey("authorization.chain.hive1.ranger.service.name"));
Review Comment:
I think you need to check if `test833` and `test899` are in the Ranger
service repo.
--
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]