morningman commented on code in PR #40750:
URL: https://github.com/apache/doris/pull/40750#discussion_r1771185917


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/AccessControllerManager.java:
##########
@@ -54,17 +57,46 @@ public class AccessControllerManager {
     private Auth auth;
     private CatalogAccessController defaultAccessController;
     private Map<String, CatalogAccessController> ctlToCtlAccessController = 
Maps.newConcurrentMap();
+    private ConcurrentHashMap<String, AccessControllerFactory> 
accessControllerFactoriesCache

Review Comment:
   Add comment to explain key and value of the map



##########
fe/fe-core/src/main/java/org/apache/doris/plugin/PropertiesUtils.java:
##########
@@ -0,0 +1,52 @@
+// 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.plugin;
+
+import org.apache.doris.common.EnvUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class PropertiesUtils {
+    public static final String ACCESS_PROPERTIES_FILE_DIR = 
"/conf/access.conf";

Review Comment:
   Better be a FE config



##########
fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/AccessControllerManager.java:
##########
@@ -54,17 +57,46 @@ public class AccessControllerManager {
     private Auth auth;
     private CatalogAccessController defaultAccessController;
     private Map<String, CatalogAccessController> ctlToCtlAccessController = 
Maps.newConcurrentMap();
+    private ConcurrentHashMap<String, AccessControllerFactory> 
accessControllerFactoriesCache
+            = new ConcurrentHashMap<>();
+    private ConcurrentHashMap<String, String> accessControllerClassNameMapping 
= new ConcurrentHashMap<>();
 
     public AccessControllerManager(Auth auth) {
         this.auth = auth;
-        if (Config.access_controller_type.equalsIgnoreCase("ranger-doris")) {
-            defaultAccessController = new 
RangerCacheDorisAccessController("doris");
-        } else {
-            defaultAccessController = new InternalAccessController(auth);
-        }
+        loadAccessControllerPlugins();
+        String accessControllerName = Config.access_controller_type;
+        this.defaultAccessController = 
loadAccessControllerOrDefault(accessControllerName);
         ctlToCtlAccessController.put(InternalCatalog.INTERNAL_CATALOG_NAME, 
defaultAccessController);
     }
 
+    private CatalogAccessController loadAccessControllerOrDefault(String 
accessControllerName) {
+        if (accessControllerName.equalsIgnoreCase("default")) {
+            return new InternalAccessController(auth);
+        }
+        if (accessControllerFactoriesCache.containsKey(accessControllerName)) {
+            Map<String, String> prop;
+            try {
+                prop = PropertiesUtils.loadAccessControllerPropertiesOrNull();
+            } catch (IOException e) {
+                LOG.warn("Failed to load access controller properties,Using 
default access controller plugin", e);
+                return new InternalAccessController(auth);

Review Comment:
   I think we should stop process if user specified access controller is not 
found



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to