frankgh commented on code in PR #201:
URL: https://github.com/apache/cassandra-sidecar/pull/201#discussion_r1984133917
##########
server/src/main/java/org/apache/cassandra/sidecar/utils/AuthUtils.java:
##########
@@ -62,4 +66,21 @@ public static List<String> extractIdentities(User user)
}
return Collections.unmodifiableList(identities);
}
+
+ /**
+ * Extracts a list of cassandra roles associated with given user.
+ *
+ * @param user User representation in Vertx
+ * @return {@code List} of cassandra roles associated with user
+ */
+ public static List<String> extractCassandraRoles(User user)
+ {
+ // noinspection unchecked
+ JsonArray roles =
user.attributes().getJsonArray(CASSANDRA_ROLES_ATTRIBUTE_NAME,
EMPTY_JSON_ARRAY);
+ if (roles == null)
+ {
+ return List.of();
+ }
+ return roles.getList();
Review Comment:
can `roles` be `null`? can we change this to this instead if that's the case?
```suggestion
return
Objects.requireNonNullElse(user.attributes().getJsonArray(CASSANDRA_ROLES_ATTRIBUTE_NAME),
EMPTY_JSON_ARRAY).getList();
```
--
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]