You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Yulei-Yang (via GitHub)" <gi...@apache.org> on 2023/02/26 16:22:25 UTC

[GitHub] [doris] Yulei-Yang opened a new pull request, #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Yulei-Yang opened a new pull request, #17153:
URL: https://github.com/apache/doris/pull/17153

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [x] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121652561


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121671597


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1118306757


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessControllerFactory.java:
##########
@@ -0,0 +1,46 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.mysql.privilege.AccessControllerFactory;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class RangerHiveAccessControllerFactory implements AccessControllerFactory {
+
+    private static volatile Map<String, RangerHiveAccessController> controllerMap = new HashMap<>();

Review Comment:
   There is a AccessControllerManager to save all AccessControllers, why do we need this `controllerMap` here?



##########
fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CatalogAccessController.java:
##########
@@ -25,39 +25,38 @@
 public interface CatalogAccessController {
     // ==== Catalog ====
     default boolean checkCtlPriv(boolean hasGlobal, UserIdentity currentUser, String ctl, PrivPredicate wanted) {
-        boolean res = checkCtlPriv(currentUser, ctl, wanted);
-        return hasGlobal || res;
+        return hasGlobal || checkCtlPriv(currentUser, ctl, wanted);

Review Comment:
   I wrote the origin code on purpose, because we need to make sure that `checkCtlPriv/checkDbPriv/....` are called everytime, or the plugin can not audit these requests.
   
   If using `hasGlobal || checkCtlPriv(currentUser, ctl, wanted);`, and when `hasGlobal` is true, the `checkCtlPriv()` will not be called



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());

Review Comment:
   It is strange to create `RangerHiveAuditHandler` for each `checkPrivileges()` call.



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);

Review Comment:
   I saw in `isAccessAllowed()`, it already call the `auditHandler.processResult()`, why do we need to call it again here?



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,

Review Comment:
   ```suggestion
       private boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");

Review Comment:
   remove these temporary debug log



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();

Review Comment:
   What is the flush policy? eg, where and when should we call this `flushAudit()` mannually?



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");
+            return true;
+        } else {
+            LOG.warn(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            return false;
+        }
+    }
+
+    public void getFilterExpr(UserIdentity currentUser, HiveAccessType accessType,
+                              RangerHiveResource resource) throws HiveAccessControlException {
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        LOG.debug("getFilterExpr: " + result.getFilterExpr());
+    }
+
+    public void getColumnMask(UserIdentity currentUser, HiveAccessType accessType,
+                              RangerHiveResource resource) {
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        LOG.debug("getColumnMask:" + result.getMaskType());

Review Comment:
   merge into one LOG line



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,

Review Comment:
   ```suggestion
       private void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveResource.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.doris.catalog.authorizer;
+
+import org.apache.ranger.plugin.policyengine.RangerAccessResourceImpl;
+
+public class RangerHiveResource extends RangerAccessResourceImpl {
+    public static final String KEY_DATABASE = "database";
+    public static final String KEY_TABLE = "table";
+    public static final String KEY_UDF = "udf";
+    public static final String KEY_COLUMN = "column";
+    private HiveObjectType objectType = null;
+
+    //FirstLevelResource => Database
+    //SecondLevelResource => Table or UDF
+    //ThirdLevelResource => column
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource) {
+        this(objectType, firstLevelResource, null, null);
+    }
+
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource, String secondLevelResource) {
+        this(objectType, firstLevelResource, secondLevelResource, null);
+    }
+
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource, String secondLevelResource,
+                              String thirdLevelResource) {
+        this.objectType = objectType;
+
+        switch (objectType) {
+            case DATABASE:
+                setValue(KEY_DATABASE, firstLevelResource);
+                break;
+
+            case FUNCTION:
+                if (firstLevelResource == null) {

Review Comment:
   Why only change `firstLevelResource`? What about second and third?
   And I saw in `setValue`, if `value` is null, it will be removed from the `elements`.
   
   Please add some comments in code to explain.
   



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());

Review Comment:
   ```suggestion
                   LOG.debug(result.getReason());
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;

Review Comment:
   Why using static? 



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());

Review Comment:
   ditto



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");

Review Comment:
   Could we print more detail error info here?



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");
+            return true;
+        } else {
+            LOG.warn(String.format(

Review Comment:
   ```suggestion
               LOG.debug(String.format(
   ```



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121704420


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121722122


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");
+            return true;
+        } else {
+            LOG.warn(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            return false;
+        }
+    }
+
+    public void getFilterExpr(UserIdentity currentUser, HiveAccessType accessType,
+                              RangerHiveResource resource) throws HiveAccessControlException {
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        LOG.debug("getFilterExpr: " + result.getFilterExpr());
+    }
+
+    public void getColumnMask(UserIdentity currentUser, HiveAccessType accessType,
+                              RangerHiveResource resource) {
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        LOG.debug("getColumnMask:" + result.getMaskType());

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121711521


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");
+            return true;
+        } else {
+            LOG.warn(String.format(

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121705386


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121327638


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessControllerFactory.java:
##########
@@ -0,0 +1,46 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.mysql.privilege.AccessControllerFactory;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class RangerHiveAccessControllerFactory implements AccessControllerFactory {
+
+    private static volatile Map<String, RangerHiveAccessController> controllerMap = new HashMap<>();

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121714022


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveResource.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.doris.catalog.authorizer;
+
+import org.apache.ranger.plugin.policyengine.RangerAccessResourceImpl;
+
+public class RangerHiveResource extends RangerAccessResourceImpl {
+    public static final String KEY_DATABASE = "database";
+    public static final String KEY_TABLE = "table";
+    public static final String KEY_UDF = "udf";
+    public static final String KEY_COLUMN = "column";
+    private HiveObjectType objectType = null;
+
+    //FirstLevelResource => Database
+    //SecondLevelResource => Table or UDF
+    //ThirdLevelResource => column
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource) {
+        this(objectType, firstLevelResource, null, null);
+    }
+
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource, String secondLevelResource) {
+        this(objectType, firstLevelResource, secondLevelResource, null);
+    }
+
+    public RangerHiveResource(HiveObjectType objectType, String firstLevelResource, String secondLevelResource,
+                              String thirdLevelResource) {
+        this.objectType = objectType;
+
+        switch (objectType) {
+            case DATABASE:
+                setValue(KEY_DATABASE, firstLevelResource);
+                break;
+
+            case FUNCTION:
+                if (firstLevelResource == null) {

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1445567801

   run feut


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1118353546


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/CatalogAccessController.java:
##########
@@ -25,39 +25,38 @@
 public interface CatalogAccessController {
     // ==== Catalog ====
     default boolean checkCtlPriv(boolean hasGlobal, UserIdentity currentUser, String ctl, PrivPredicate wanted) {
-        boolean res = checkCtlPriv(currentUser, ctl, wanted);
-        return hasGlobal || res;
+        return hasGlobal || checkCtlPriv(currentUser, ctl, wanted);

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1118365610


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121710172


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");

Review Comment:
   fixed



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();
+
+        if (result == null) {
+            LOG.warn("Error getting authorizer result, please check your ranger config");
+            return false;
+        }
+
+        if (result.getIsAllowed()) {
+            LOG.debug("pass");

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121820138


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);
+            if (!result.getIsAllowed()) {
+                LOG.warn(result.getReason());
+                throw new AuthorizationException(String.format(
+                    "Permission denied: user [%s] does not have privilege for [%s] command on [%s]",
+                    currentUser.getQualifiedUser(), accessType.name(),
+                    result.getAccessRequest().getResource().getAsString()));
+            }
+        }
+    }
+
+    public boolean checkPrivilege(UserIdentity currentUser, HiveAccessType accessType,
+                                  RangerHiveResource resource) {
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+        request.setResource(resource);
+
+        RangerAccessResult result = hivePlugin.isAccessAllowed(request, auditHandler);
+        auditHandler.processResult(result);
+        auditHandler.flushAudit();

Review Comment:
   will add a timer thread to flush audit log in next pr



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morningman merged pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman merged PR #17153:
URL: https://github.com/apache/doris/pull/17153


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1121678118


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;
+
+    public RangerHiveAccessController(Map<String, String> properties) {
+        String serviceName = properties.get("ranger.service.name");
+        hivePlugin = new RangerHivePlugin(serviceName);
+    }
+
+    private RangerAccessRequestImpl createRequest(UserIdentity currentUser, HiveAccessType accessType) {
+        RangerAccessRequestImpl request = new RangerAccessRequestImpl();
+        request.setUser(currentUser.getQualifiedUser());
+        request.setUserRoles(currentUser.getRoles());
+        request.setAction(accessType.name());
+        if (accessType == HiveAccessType.USE) {
+            request.setAccessType(RangerPolicyEngine.ANY_ACCESS);
+        } else {
+            request.setAccessType(accessType.name().toLowerCase());
+        }
+        request.setClientIPAddress(currentUser.getHost());
+        request.setClientType(CLIENT_TYPE_DORIS);
+        request.setAccessTime(new Date());
+
+        return request;
+    }
+
+    public void checkPrivileges(UserIdentity currentUser, HiveAccessType accessType,
+                                List<RangerHiveResource> hiveResources) throws AuthorizationException {
+        List<RangerAccessRequest> requests = new ArrayList<>();
+        for (RangerHiveResource resource : hiveResources) {
+            RangerAccessRequestImpl request = createRequest(currentUser, accessType);
+            request.setResource(resource);
+
+            requests.add(request);
+        }
+
+        RangerHiveAuditHandler auditHandler = new RangerHiveAuditHandler(hivePlugin.getConfig());
+        Collection<RangerAccessResult> results = hivePlugin.isAccessAllowed(requests, auditHandler);
+        for (RangerAccessResult result : results) {
+            LOG.debug("match policy:" + result.getPolicyId());
+            LOG.debug("will audit: " + result.toString());
+            auditHandler.processResult(result);

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1451107323

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on a diff in pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on code in PR #17153:
URL: https://github.com/apache/doris/pull/17153#discussion_r1118364362


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/authorizer/RangerHiveAccessController.java:
##########
@@ -0,0 +1,188 @@
+// 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.doris.catalog.authorizer;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.AuthorizationException;
+import org.apache.doris.mysql.privilege.CatalogAccessController;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
+import org.apache.ranger.plugin.policyengine.RangerAccessRequestImpl;
+import org.apache.ranger.plugin.policyengine.RangerAccessResult;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngine;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class RangerHiveAccessController implements CatalogAccessController {
+    public static final String CLIENT_TYPE_DORIS = "doris";
+    private static final Logger LOG = LogManager.getLogger(RangerHiveAccessController.class);
+    private static volatile RangerHivePlugin hivePlugin = null;

Review Comment:
   fixed



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1445404805

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Yulei-Yang commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "Yulei-Yang (via GitHub)" <gi...@apache.org>.
Yulei-Yang commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1445523236

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1445413164

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 36.38 seconds
    stream load tsv:          479 seconds loaded 74807831229 Bytes, about 148 MB/s
    stream load json:         38 seconds loaded 2358488459 Bytes, about 59 MB/s
    stream load orc:          67 seconds loaded 1101869774 Bytes, about 15 MB/s
    stream load parquet:          28 seconds loaded 861443392 Bytes, about 29 MB/s
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230226171803_clickbench_pr_104638.html


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1452815839

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #17153: [Improvement](auth)(step-1) add ranger authorizer for hms catalog

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17153:
URL: https://github.com/apache/doris/pull/17153#issuecomment-1452815862

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org