sajjad-moradi commented on code in PR #9252:
URL: https://github.com/apache/pinot/pull/9252#discussion_r951980666


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/access/AccessControl.java:
##########
@@ -51,7 +52,8 @@ public interface AccessControl {
    * @param endpointUrl the request url for which this access control is called
    * @return whether the client has permission
    */
-  default boolean hasAccess(String tableName, AccessType accessType, 
HttpHeaders httpHeaders, String endpointUrl) {
+  default boolean hasAccess(@Nullable String tableName, AccessType accessType, 
HttpHeaders httpHeaders,

Review Comment:
   I believe we shouldn't make these nullable. The existing implementations 
might assume these are not null.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -193,7 +198,7 @@ private String getQueryResponse(String query, @Nullable 
SqlNode sqlNode, String
 
     // Validate data access
     AccessControl accessControl = _accessControlFactory.create();
-    if (!accessControl.hasDataAccess(httpHeaders, rawTableName)) {
+    if (!accessControl.hasAccess(rawTableName, AccessType.READ, httpHeaders, 
endpointUrl)) {

Review Comment:
   Let's not change this. Although we're reading data and AccessType.READ looks 
appropriate, we need to only allow ppl who are authorized to be able to query 
the data that might contain sensitive info like user information. It's 
different than reading table config or some other cluster configs that might be 
ok with weaker authentication level like AccessType.READ.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentUploadDownloadRestletResource.java:
##########
@@ -139,24 +138,12 @@ public class PinotSegmentUploadDownloadRestletResource {
   @Produces(MediaType.APPLICATION_OCTET_STREAM)
   @Path("/segments/{tableName}/{segmentName}")
   @ApiOperation(value = "Download a segment", notes = "Download a segment")
+  @Authenticate(AccessType.READ)
   public Response downloadSegment(
       @ApiParam(value = "Name of the table", required = true) 
@PathParam("tableName") String tableName,
       @ApiParam(value = "Name of the segment", required = true) 
@PathParam("segmentName") @Encoded String segmentName,
       @Context HttpHeaders httpHeaders)
       throws Exception {
-    // Validate data access
-    boolean hasDataAccess;
-    try {
-      AccessControl accessControl = _accessControlFactory.create();
-      hasDataAccess = accessControl.hasDataAccess(httpHeaders, tableName);
-    } catch (Exception e) {
-      throw new ControllerApplicationException(LOGGER,
-          "Caught exception while validating access to table: " + tableName, 
Response.Status.INTERNAL_SERVER_ERROR, e);
-    }
-    if (!hasDataAccess) {
-      throw new ControllerApplicationException(LOGGER, "No data access to 
table: " + tableName,
-          Response.Status.FORBIDDEN);
-    }
 

Review Comment:
   We shouldn't delete the manual authentication here. Although the method is 
GET, but we need to only allow ppl who are authorized to be able to download 
the data. 



-- 
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

Reply via email to