[ 
https://issues.apache.org/jira/browse/HIVE-25468?focusedWorklogId=648804&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-648804
 ]

ASF GitHub Bot logged work on HIVE-25468:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Sep/21 18:33
            Start Date: 09/Sep/21 18:33
    Worklog Time Spent: 10m 
      Work Description: saihemanth-cloudera commented on a change in pull 
request #2595:
URL: https://github.com/apache/hive/pull/2595#discussion_r705599282



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/metastore/events/DropFunctionEvent.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.hadoop.hive.ql.security.authorization.plugin.metastore.events;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hive.metastore.api.Function;
+import org.apache.hadoop.hive.metastore.api.ResourceUri;
+import org.apache.hadoop.hive.metastore.events.PreCreateFunctionEvent;
+import org.apache.hadoop.hive.metastore.events.PreDropFunctionEvent;
+import org.apache.hadoop.hive.metastore.events.PreEventContext;
+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.metastore.HiveMetaStoreAuthorizableEvent;
+import 
org.apache.hadoop.hive.ql.security.authorization.plugin.metastore.HiveMetaStoreAuthzInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/*
+ Authorizable Event for HiveMetaStore operation DropFunction
+ */
+public class DropFunctionEvent extends HiveMetaStoreAuthorizableEvent {
+    private static final Logger LOG = 
LoggerFactory.getLogger(DropFunctionEvent.class);
+
+    private String COMMAND_STR = "drop function";
+
+    public DropFunctionEvent(PreEventContext preEventContext) {
+        super(preEventContext);
+    }
+
+    @Override
+    public HiveMetaStoreAuthzInfo getAuthzContext() {
+        HiveMetaStoreAuthzInfo ret = new 
HiveMetaStoreAuthzInfo(preEventContext, HiveOperationType.DROPFUNCTION, 
getInputHObjs(), getOutputHObjs(), COMMAND_STR);
+
+        return ret;
+    }
+
+    private List<HivePrivilegeObject> getInputHObjs() {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("==> DropFunctionEvent.getInputHObjs()");
+        }
+        List<HivePrivilegeObject> ret   = new ArrayList<>();
+        PreDropFunctionEvent event = (PreDropFunctionEvent) preEventContext;
+        Function function = event.getFunction();
+        List<ResourceUri> uris   = function.getResourceUris();
+        ret.add(new 
HivePrivilegeObject(HivePrivilegeObject.HivePrivilegeObjectType.FUNCTION, 
function.getDbName(), function.getFunctionName(), null,
+                null, HivePrivilegeObject.HivePrivObjectActionType.OTHER, 
null, function.getClassName(), function.getOwnerName(), 
function.getOwnerType()));

Review comment:
       We need to send HivePrivilegeObject.HivePrivObjectActionType as OTHER 
since Ranger is expecting OTHER as action type. If the action type is other, 
Ranger would check HivePrivilege Object type and do the required action.




-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 648804)
    Time Spent: 1h 20m  (was: 1h 10m)

> Create/Drop functions should be authorized in HMS
> -------------------------------------------------
>
>                 Key: HIVE-25468
>                 URL: https://issues.apache.org/jira/browse/HIVE-25468
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive
>            Reporter: Sai Hemanth Gantasala
>            Assignee: Sai Hemanth Gantasala
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Create function func_name using class 'org.someclass' using jar 
> '/path_to_jar';
> Drop function func_name;
> These commands are currently authorized in HS2 but not in HiveMetastore. 
> These commands should be authorized for HMS clients for (eg:spark-shell) on 
> the end-user.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to