apucher commented on a change in pull request #6613: URL: https://github.com/apache/incubator-pinot/pull/6613#discussion_r592800726
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/BasicAuthAccessControlFactory.java ########## @@ -0,0 +1,106 @@ +/** + * 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.controller.api.access; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.ws.rs.core.HttpHeaders; +import org.apache.pinot.core.auth.BasicAuthPrincipal; +import org.apache.pinot.core.auth.BasicAuthUtils; +import org.apache.pinot.spi.env.PinotConfiguration; + + +/** + * Basic Authentication based on http headers. Configured via the "controller.admin.access.control" family of properties. + * + * <pre> + * Example: + * controller.admin.access.control.principals=admin123,user456 + * controller.admin.access.control.principals.admin123.password=verysecret + * controller.admin.access.control.principals.user456.password=kindasecret + * controller.admin.access.control.principals.user456.tables=stuff,lessImportantStuff + * controller.admin.access.control.principals.user456.permissions=read,update + * </pre> + */ +public class BasicAuthAccessControlFactory implements AccessControlFactory { + private static final String PREFIX = "controller.admin.access.control.principals"; + + private static final String HEADER_AUTHORIZATION = "Authorization"; + + private AccessControl _accessControl; + + public void init(PinotConfiguration configuration) { + _accessControl = new BasicAuthAccessControl(BasicAuthUtils.extractBasicAuthPrincipals(configuration, PREFIX)); + } + + @Override + public AccessControl create() { + return _accessControl; Review comment: I have to maintain compatibility with the existing interfaces. pinot's config management isn't great, and this seems to be the only graceful way of getting access to pinot's config properties ---------------------------------------------------------------- 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. 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