xiangfu0 commented on code in PR #17242:
URL: https://github.com/apache/pinot/pull/17242#discussion_r2643153962
##########
pinot-broker/src/main/java/org/apache/pinot/broker/broker/ZkBasicAuthAccessControlFactory.java:
##########
@@ -122,24 +122,39 @@ public TableAuthorizationResult
authorize(RequesterIdentity requesterIdentity, S
private Optional<ZkBasicAuthPrincipal> getPrincipalAuth(RequesterIdentity
requesterIdentity) {
Collection<String> tokens =
extractAuthorizationTokens(requesterIdentity);
- if (tokens.isEmpty()) {
+ if (tokens == null || tokens.isEmpty()) {
return Optional.empty();
}
- _name2principal =
BasicAuthUtils.extractBasicAuthPrincipals(_userCache.getAllBrokerUserConfig()).stream()
- .collect(Collectors.toMap(BasicAuthPrincipal::getName, p -> p));
+ Map<String, ZkBasicAuthPrincipal> name2principal =
+
BasicAuthUtils.extractBasicAuthPrincipals(_userCache.getAllBrokerUserConfig()).stream()
+ .collect(Collectors.toMap(BasicAuthPrincipal::getName, p -> p));
- Map<String, String> name2password = tokens.stream().collect(
- Collectors.toMap(
- org.apache.pinot.common.auth.BasicAuthUtils::extractUsername,
- org.apache.pinot.common.auth.BasicAuthUtils::extractPassword,
- (v1, v2) -> v2));
- Map<String, ZkBasicAuthPrincipal> password2principal =
-
name2password.keySet().stream().collect(Collectors.toMap(name2password::get,
_name2principal::get));
+ for (String token : tokens) {
+ String username =
org.apache.pinot.common.auth.BasicAuthUtils.extractUsername(token);
Review Comment:
import class `org.apache.pinot.common.auth.BasicAuthUtils` and just do
```
String username = BasicAuthUtils.extractUsername(token);
```
##########
pinot-broker/src/main/java/org/apache/pinot/broker/broker/ZkBasicAuthAccessControlFactory.java:
##########
@@ -122,24 +122,39 @@ public TableAuthorizationResult
authorize(RequesterIdentity requesterIdentity, S
private Optional<ZkBasicAuthPrincipal> getPrincipalAuth(RequesterIdentity
requesterIdentity) {
Collection<String> tokens =
extractAuthorizationTokens(requesterIdentity);
- if (tokens.isEmpty()) {
+ if (tokens == null || tokens.isEmpty()) {
return Optional.empty();
}
- _name2principal =
BasicAuthUtils.extractBasicAuthPrincipals(_userCache.getAllBrokerUserConfig()).stream()
- .collect(Collectors.toMap(BasicAuthPrincipal::getName, p -> p));
+ Map<String, ZkBasicAuthPrincipal> name2principal =
+
BasicAuthUtils.extractBasicAuthPrincipals(_userCache.getAllBrokerUserConfig()).stream()
+ .collect(Collectors.toMap(BasicAuthPrincipal::getName, p -> p));
- Map<String, String> name2password = tokens.stream().collect(
- Collectors.toMap(
- org.apache.pinot.common.auth.BasicAuthUtils::extractUsername,
- org.apache.pinot.common.auth.BasicAuthUtils::extractPassword,
- (v1, v2) -> v2));
- Map<String, ZkBasicAuthPrincipal> password2principal =
-
name2password.keySet().stream().collect(Collectors.toMap(name2password::get,
_name2principal::get));
+ for (String token : tokens) {
+ String username =
org.apache.pinot.common.auth.BasicAuthUtils.extractUsername(token);
+ String password =
org.apache.pinot.common.auth.BasicAuthUtils.extractPassword(token);
Review Comment:
``` String password = BasicAuthUtils.extractPassword(token);```
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotControllerAuthResource.java:
##########
@@ -81,7 +81,7 @@ public boolean verify(@ApiParam(value = "Table name without
type") @QueryParam("
@ApiParam(value = "API access type") @DefaultValue("READ")
@QueryParam("accessType") AccessType accessType,
@ApiParam(value = "Endpoint URL") @QueryParam("endpointUrl") String
endpointUrl) {
AccessControl accessControl = _accessControlFactory.create();
- return accessControl.hasAccess(tableName, accessType, _httpHeaders,
endpointUrl);
+ return accessControl.hasAccess(_httpHeaders, TargetType.CLUSTER);
Review Comment:
In this case, I feel we should just mark this API deprecated and create new
APIs for this.
--
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]