frankgh commented on code in PR #223:
URL: https://github.com/apache/cassandra-sidecar/pull/223#discussion_r2138702636


##########
server/src/main/java/org/apache/cassandra/sidecar/acl/authentication/MutualTlsAuthenticationHandler.java:
##########
@@ -88,10 +91,19 @@ public void authenticate(RoutingContext ctx, 
Handler<AsyncResult<User>> handler)
 
                         List<String> identities = 
extractIdentities(authN.result());
                         List<String> roles = extractCassandraRoles(identities);
-                        if (!roles.isEmpty())
+                        String roleIntended = 
ctx.request().getHeader(AUTH_ROLE);
+
+                        if (isNotEmpty(roleIntended) && 
!roles.contains(roleIntended))
                         {
-                            
authN.result().attributes().put(CASSANDRA_ROLES_ATTRIBUTE_NAME, roles);
+                            String errMsg = String.format("None of the 
identities %s are authorized for role %s",
+                                                          identities, 
roleIntended);
+                            
handler.handle(Future.failedFuture(wrapHttpException(UNAUTHORIZED, errMsg)));
+                            return;
                         }
+
+                        List<String> rolesToAdd = roleIntended != null && 
!roleIntended.isEmpty()

Review Comment:
   NIT, since you are already using it
   ```suggestion
                           List<String> rolesToAdd = isNotEmpty(roleIntended)
   ```



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to