mcvsubbu commented on a change in pull request #6440: URL: https://github.com/apache/incubator-pinot/pull/6440#discussion_r564699735
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessControl.java ########## @@ -30,9 +30,35 @@ /** * Return whether the client has data access to the given table. * + * Note: This method is only used for read access. It will be deprecated soon and its usage will be replaced by Review comment: You mean, this method will be removed soon, right? In that case, you should mark it deprecated, and leave it here for one release. ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessControl.java ########## @@ -30,9 +30,35 @@ /** * Return whether the client has data access to the given table. * + * Note: This method is only used for read access. It will be deprecated soon and its usage will be replaced by + * `hasAccess` method with AccessType.READ. + * * @param httpHeaders Http headers * @param tableName Name of the table to be accessed * @return Whether the client has data access to the table */ boolean hasDataAccess(HttpHeaders httpHeaders, String tableName); + + /** + * Return whether the client has permission to the given table + * + * @param accessType access type + * @param httpHeaders HTTP headers + * @param tableName Name of the table to be accessed + * @return whether the client has permission + */ + default boolean hasAccess(AccessType accessType, HttpHeaders httpHeaders, String tableName) { + return true; + } + + /** + * Return whether the client has permission to access the endpoints which are not table level Review comment: It may be good to keep this API extensible, is to add the endpoint name (and version) and the operation (CRUD) in the API. The authenticator can then choose to (for example) allow adding a new table, but not modifying any existing table or schema. Or, allow adding segments to a table, but not deleting segments. ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessType.java ########## @@ -0,0 +1,24 @@ +/** + * 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; + +public enum AccessType { + READ, WRITE Review comment: Should we have CREATE, READ, UPDATE, DELETE? May keep this extensible for the future. ########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessControlUtils.java ########## @@ -0,0 +1,65 @@ +/** + * 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 javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; +import org.apache.pinot.controller.api.resources.ControllerApplicationException; +import org.apache.pinot.spi.utils.builder.TableNameBuilder; +import org.slf4j.Logger; + + +public class AccessControlUtils { + + public static void validateWritePermission(HttpHeaders httpHeaders, String tableName, Review comment: Please add javadocs for these methods. It looks like these are supposed to be used by REST api end points (since throw specific exceptions). Also, if you can find a way to avoid static methods that will be super helpful. It will be useful to write unit tests where access control returns can be tested. ---------------------------------------------------------------- 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