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


##########
server/src/main/java/org/apache/cassandra/sidecar/acl/authentication/ReloadingJwtAuthenticationHandler.java:
##########
@@ -105,10 +108,18 @@ public void authenticate(RoutingContext context, 
Handler<AsyncResult<User>> hand
             }
 
             List<String> roles = extractCassandraRoles(decodedToken);
-            if (!roles.isEmpty())
+            String roleIntended = context.request().getHeader(AUTH_ROLE);
+
+            if (isNotEmpty(roleIntended) && !roles.contains(roleIntended))
             {
-                user.attributes().put(CASSANDRA_ROLES_ATTRIBUTE_NAME, roles);
+                String errMsg = String.format("User not authorized for role 
%s", roleIntended);
+                
handler.handle(Future.failedFuture(wrapHttpException(UNAUTHORIZED, errMsg)));
+                return;
             }
+
+            List<String> rolesToAdd = roleIntended != null && 
!roleIntended.isEmpty()

Review Comment:
   NIT: since you are using isNotEmpty in this class already
   ```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