Code RoomAdmin check rejects valid tokens
HardPrep Room Coding #4527

Admin check rejects valid tokens

Code reviewCode quality & reviewSenior–Staff~20 min

Review this Java filter that authorizes admin-only routes by normalizing the role claim before comparing.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1private static final String ADMIN = "ADMIN";
2 
3boolean isAdminRole(String role) {
4 // role comes off the request token, e.g. "admin"
5 if (role == null) {
6 return false;
7 }
8 String normalized = role.trim().toUpperCase();
9 return normalized.equals(ADMIN);
10}
11 
12void handle(Request req) {
13 if (!isAdminRole(req.role())) {
14 throw new ForbiddenException();
15 }
16 // ... privileged work
17}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.