bug: authorization is no longer hardcoded#14
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/com/smf/security/AppUserDetails.java`:
- Around line 21-30: The authorities list may contain duplicate "ADMIN" entries
when multiple roles have isAdmin() true; update the logic in AppUserDetails that
builds the authorities (currently using user.getRoles().stream().flatMap(...)
collecting to List) to deduplicate entries—e.g., emit authorities as a Stream of
SimpleGrantedAuthority for each role name and the "ADMIN" marker and then apply
distinct() (or collect into a Set and convert to List) before assigning to the
authorities variable so each granted authority (including "ADMIN") appears only
once.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 830717e0-6b57-45e6-9c9d-26e8f87f0e45
📒 Files selected for processing (1)
src/main/java/com/smf/security/AppUserDetails.java
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/com/smf/security/AppUserDetails.java`:
- Line 28: Replace the hardcoded "ADMIN" literal used when creating the granted
authority in AppUserDetails (the line roleAuths.add(new
SimpleGrantedAuthority("ADMIN"))) with a shared constant; define a single public
constant (for example ADMIN = "ADMIN") in a central place such as an
AuthorityConstants class or a Role enum, import and reference that constant
inside AppUserDetails (and update other usages in filters, annotations, and
tests to use the same constant) so all authorities are driven from one canonical
symbol instead of repeated string literals.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2d5b2480-cff0-4f97-85a6-7ebceb9cc8fd
📒 Files selected for processing (1)
src/main/java/com/smf/security/AppUserDetails.java
Summary by CodeRabbit