-
-
Notifications
You must be signed in to change notification settings - Fork 727
Make group auth check case-insensitive #11610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -368,7 +368,7 @@ private boolean hasAccessToCancerStudy( | |||||||||||||||||||||||||||||||||||||||||
Arrays.stream(cancerStudy.getGroups().split(";")) | ||||||||||||||||||||||||||||||||||||||||||
.filter(g -> !g.isEmpty()) | ||||||||||||||||||||||||||||||||||||||||||
.collect(Collectors.toSet()); | ||||||||||||||||||||||||||||||||||||||||||
if (!Collections.disjoint(groups, grantedAuthorities)) { | ||||||||||||||||||||||||||||||||||||||||||
if (!caseInsensitiveDisjoint(groups, grantedAuthorities)) { | ||||||||||||||||||||||||||||||||||||||||||
if (log.isDebugEnabled()) { | ||||||||||||||||||||||||||||||||||||||||||
log.debug("hasAccessToCancerStudy(), user has access by groups return true"); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -393,6 +393,12 @@ private boolean hasAccessToCancerStudy( | |||||||||||||||||||||||||||||||||||||||||
return toReturn; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
private static boolean caseInsensitiveDisjoint(Collection<String> c1, Collection<String> c2) { | ||||||||||||||||||||||||||||||||||||||||||
Set<String> upperC1 = c1.stream().map(String::toUpperCase).collect(Collectors.toSet()); | ||||||||||||||||||||||||||||||||||||||||||
Set<String> upperC2 = c2.stream().map(String::toUpperCase).collect(Collectors.toSet()); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+397
to
+398
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stream operations should handle null elements within the collections to prevent NullPointerException when calling toUpperCase() on null strings.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
Comment on lines
+397
to
+398
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stream operations should handle null elements within the collections to prevent NullPointerException when calling toUpperCase() on null strings.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||
return Collections.disjoint(upperC1, upperC2); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
private boolean hasAccessToCancerStudy( | ||||||||||||||||||||||||||||||||||||||||||
Authentication authentication, String cancerStudyId, Object permission) { | ||||||||||||||||||||||||||||||||||||||||||
// everybody has access the 'all' cancer study | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method should include null safety checks for the input collections to prevent NullPointerException if either c1 or c2 is null.
Copilot uses AI. Check for mistakes.