davsclaus commented on code in PR #27432:
URL: https://github.com/apache/camel/pull/27432#discussion_r4194245212


##########
components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java:
##########
@@ -235,16 +237,31 @@ protected boolean matchesRoles(String roles, String 
userRoles) {
             return true;
         }
 
-        // see if any of the user roles is contained in the roles list
-        for (String userRole : ObjectHelper.createIterable(userRoles)) {
-            if (roles.contains(userRole)) {
+        // the user must have one of the roles, compared by the exact role name
+        Set<String> names = roleNames(roles);
+        for (String userRole : roleNames(userRoles)) {
+            if (names.contains(userRole)) {
                 return true;
             }
         }
 
         return false;
     }
 
+    /**
+     * The role names in the comma separated list of roles, trimmed and 
without blank entries.
+     */
+    private static Set<String> roleNames(String roles) {
+        Set<String> names = new HashSet<>();

Review Comment:
   Nit: the set is not needed, iterating `createIterable(userRoles)` and 
trimming each entry would do the same without allocating per request. Not worth 
another round on its own.



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

Reply via email to