INNOCENT-BOY commented on a change in pull request #8314: URL: https://github.com/apache/pinot/pull/8314#discussion_r829641115
########## File path: pinot-common/src/main/java/org/apache/pinot/common/config/provider/UserCache.java ########## @@ -0,0 +1,176 @@ +/** + * 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.pinot.common.config.provider; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import org.I0Itec.zkclient.IZkChildListener; +import org.I0Itec.zkclient.IZkDataListener; +import org.apache.commons.collections.CollectionUtils; +import org.apache.helix.AccessOption; +import org.apache.helix.ZNRecord; +import org.apache.helix.store.zk.ZkHelixPropertyStore; +import org.apache.pinot.common.utils.config.UserConfigUtils; +import org.apache.pinot.spi.config.user.ComponentType; +import org.apache.pinot.spi.config.user.UserConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class UserCache { + + private static final Logger LOGGER = LoggerFactory.getLogger(UserCache.class); + private static final String USER_CONFIG_PARENT_PATH = "/CONFIGS/USER"; + private static final String USER_CONFIG_PATH_PREFIX = "/CONFIGS/USER/"; + + private final ZkHelixPropertyStore<ZNRecord> _propertyStore; + + private final UserConfigChangeListener _userConfigChangeListener = new UserConfigChangeListener(); + + private final Map<String, UserConfig> _userConfigMap = new ConcurrentHashMap<>(); + private final Map<String, UserConfig> _userControllerConfigMap = new ConcurrentHashMap<>(); + private final Map<String, UserConfig> _userBrokerConfigMap = new ConcurrentHashMap<>(); + private final Map<String, UserConfig> _userServerConfigMap = new ConcurrentHashMap<>(); Review comment: @apucher I think your suggestion is more reasonable,but now Pinot haven't added access control to minion and proxy. We would get nothing information about minion and proxy. Maybe I didn't understand your point. I look forward to your reply. Thx ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessControlUtils.java ########## @@ -93,4 +93,21 @@ public void validatePermission(Optional<String> tableNameOpt, AccessType accessT Response.Status.FORBIDDEN); } } + + public void validatePermission(HttpHeaders httpHeaders, String endpointUrl, + AccessControl accessControl) { + validatePermission("you", httpHeaders, endpointUrl, accessControl); Review comment: @apucher The original idea is to reuse the same name method. Now I have integrated the two methods into one. I have deleted this abrupt word "you". ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java ########## @@ -1268,6 +1274,32 @@ public Schema getSchemaForTableConfig(TableConfig tableConfig) { AccessOption.PERSISTENT); } + public void initUserACLConfig() throws IOException { + if (Optional.ofNullable(ZKMetadataProvider.getAllUserName(_propertyStore)).isEmpty()) { + addUser(new UserConfig("admin", "Pda@wap%admin", ComponentType.CONTROLLER.name(), + RoleType.ADMIN.name(), null, null)); + addUser(new UserConfig("admin", "Pda@wap%admin", ComponentType.BROKER.name(), + RoleType.ADMIN.name(), null, null)); + addUser(new UserConfig("admin", "Pda@wap%admin", ComponentType.SERVER.name(), + RoleType.ADMIN.name(), null, null)); + } Review comment: @apucher You are right. I have set DEFAULT_ACCESS_CONTROL_USERNAME and DEFAULT_ACCESS_CONTROL_PASSWORD. These two variables have default value. And user can set these two value via controller configuration file. ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/config/user/ComponentType.java ########## @@ -0,0 +1,23 @@ +/** + * 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.pinot.spi.config.user; + +public enum ComponentType { + CONTROLLER, BROKER, SERVER Review comment: @apucher Currently, Only Controller、broker, and server components need Auth Access Control. I haven't got the point of appending minion and proxy at here. -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org