RockteMQ-AI commented on code in PR #2341:
URL:
https://github.com/apache/rocketmq-dashboard/pull/2341#discussion_r3801313412
##########
server/src/main/java/org/apache/rocketmq/studio/auth/AuthenticatedUserContext.java:
##########
@@ -25,24 +25,36 @@ public final class AuthenticatedUserContext {
public static final String SYSTEM_ACTOR = "system";
private static final ThreadLocal<String> CURRENT_USERNAME = new
ThreadLocal<>();
+ private static final ThreadLocal<Boolean> CURRENT_ADMIN = new
ThreadLocal<>();
private AuthenticatedUserContext() {
}
- public static void setUsername(String username) {
+ public static void setUser(String username, boolean admin) {
if (username == null || username.isBlank()) {
clear();
return;
}
CURRENT_USERNAME.set(username);
+ CURRENT_ADMIN.set(admin);
+ }
+
+ public static void setUsername(String username) {
+ setUser(username, false);
}
public static String currentUsernameOrSystem() {
String username = CURRENT_USERNAME.get();
return username == null ? SYSTEM_ACTOR : username;
}
+ public static boolean currentUserIsAdminOrSystem() {
Review Comment:
**[Info]** `currentUserIsAdminOrSystem()` returns `true` when
`CURRENT_ADMIN` is `null` — this is correct for the unauthenticated/system
case, but worth a brief Javadoc comment explaining why `null` defaults to
admin. Future maintainers might otherwise assume it's a missing initialization.
--
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]