Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-14 Thread via GitHub


saihemanth-cloudera commented on PR #6479:
URL: https://github.com/apache/hive/pull/6479#issuecomment-4453493696

   https://issues.apache.org/jira/browse/HIVE-29228 - mostly covers what I want 
to do here. I'll close this PR and review/collaborate on the other PR. I'll 
reopen this later if the other PR doesn't entirely solve this 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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-14 Thread via GitHub


saihemanth-cloudera closed pull request #6479: HIVE-29581: Add support for 
write operation in Rest Catalog
URL: https://github.com/apache/hive/pull/6479


-- 
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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-13 Thread via GitHub


deniskuzZ commented on PR #6479:
URL: https://github.com/apache/hive/pull/6479#issuecomment-4440702403

   This PR does not add write support. It adds authorization checks for write 
operations that already existed.
   @saihemanth-cloudera could you please update the PR title and description


-- 
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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-12 Thread via GitHub


henrib commented on PR #6479:
URL: https://github.com/apache/hive/pull/6479#issuecomment-4438176694

   There might be some overlap with 
https://issues.apache.org/jira/browse/HIVE-29228 .


-- 
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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-12 Thread via GitHub


difin commented on PR #6479:
URL: https://github.com/apache/hive/pull/6479#issuecomment-4435144930

   Are there any tests for write operations on the HMS REST Catalog?


-- 
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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-12 Thread via GitHub


difin commented on code in PR #6479:
URL: https://github.com/apache/hive/pull/6479#discussion_r3230053900


##
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/PrivilegeHelper.java:
##
@@ -0,0 +1,142 @@
+/*
+ * 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.iceberg.rest;
+
+import java.util.Collections;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.metadata.HiveUtils;
+import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzSessionContext;
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizer;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizerFactory;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveMetastoreClientFactoryImpl;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject.HivePrivilegeObjectType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Uses the configured HiveAuthorizerFactory to enforce write-access checks at 
the REST
+ * catalog layer before any underlying catalog operation is attempted. When no 
authorizer is
+ * available the helper logs a warning and fails open (allows the request 
through).
+ */
+class PrivilegeHelper {
+  private static final Logger LOG = 
LoggerFactory.getLogger(PrivilegeHelper.class);
+
+  private final HiveAuthorizer authorizer;
+  private final HiveAuthzContext authzContext;
+
+  PrivilegeHelper(Configuration conf) {
+HiveAuthorizer auth = null;
+HiveConf hiveConf = (conf instanceof HiveConf) ? (HiveConf) conf
+: new HiveConf(conf, PrivilegeHelper.class);
+try {
+  HiveAuthorizerFactory factory = HiveUtils.getAuthorizerFactory(
+  hiveConf, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER);
+  if (factory != null) {
+HiveAuthzSessionContext.Builder authzContextBuilder = new 
HiveAuthzSessionContext.Builder();
+
authzContextBuilder.setClientType(HiveAuthzSessionContext.CLIENT_TYPE.HIVEMETASTORE);
+authzContextBuilder.setSessionString("REST_CATALOG_PrivilegeHelper");
+HiveAuthzSessionContext sessionContext = authzContextBuilder.build();
+
+HiveAuthenticationProvider authenticator = HiveUtils.getAuthenticator(
+hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHENTICATOR_MANAGER);
+if (authenticator != null) {
+  authenticator.setConf(hiveConf);
+}
+
+auth = factory.createHiveAuthorizer(
+new HiveMetastoreClientFactoryImpl(hiveConf), hiveConf, 
authenticator, sessionContext);
+LOG.info("PrivilegeHelper initialized with authorizer: {}", 
auth.getClass().getName());
+  } else {
+LOG.warn("PrivilegeHelper: no authorizer factory configured; 
write-access enforcement is disabled");
+  }
+} catch (Exception e) {
+  LOG.error("PrivilegeHelper: failed to initialize authorizer; 
write-access enforcement is disabled", e);
+}
+this.authorizer = auth;
+HiveAuthzContext.Builder builder = new HiveAuthzContext.Builder();
+builder.setCommandString("REST catalog write operation");
+this.authzContext = builder.build();
+  }
+
+  boolean isAvailable() {

Review Comment:
   It would be better to change the method name to something more meaningful, 
like `isAuthorizerAvailable`.



-- 
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] HIVE-29581: Add support for write operation in Rest Catalog [hive]

2026-05-12 Thread via GitHub


saihemanth-cloudera commented on PR #6479:
URL: https://github.com/apache/hive/pull/6479#issuecomment-4435033891

   @henrib Can you review these changes?


-- 
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]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]