Add Fine-Grained Scope Validation for SCIM2 Bulk API#649
Draft
asha15 wants to merge 5 commits into
Draft
Conversation
mpmadhavig
reviewed
Aug 6, 2025
Comment on lines
+1091
to
+1099
| List<String> authorizedScopes = (List<String>) IdentityUtil.threadLocalProperties.get().get( | ||
| SCIMCommonConstants.AUTHORIZED_SCOPES); | ||
|
|
||
| if (authorizedScopes != null && | ||
| requiredScopes.stream().noneMatch(authorizedScopes::contains)) { | ||
| throw new ForbiddenException( | ||
| "Operation is not permitted. You do not have permissions to make this request."); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Change this to get the scopes from privileged carbon context.
mpmadhavig
reviewed
Aug 6, 2025
Comment on lines
+129
to
+131
| SCIMCommonUtils.validateAuthorizedScopes(Arrays.asList( | ||
| "internal_bulk_resource_create", "internal_bulk_role_create", | ||
| "internal_org_bulk_resource_create", "internal_org_bulk_role_create")); |
Contributor
There was a problem hiding this comment.
Get these from resource access control file.
mpmadhavig
reviewed
Aug 6, 2025
Comment on lines
+1088
to
+1099
| public static void validateAuthorizedScopes(List<String> requiredScopes) | ||
| throws ForbiddenException { | ||
|
|
||
| List<String> authorizedScopes = (List<String>) IdentityUtil.threadLocalProperties.get().get( | ||
| SCIMCommonConstants.AUTHORIZED_SCOPES); | ||
|
|
||
| if (authorizedScopes != null && | ||
| requiredScopes.stream().noneMatch(authorizedScopes::contains)) { | ||
| throw new ForbiddenException( | ||
| "Operation is not permitted. You do not have permissions to make this request."); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Think about moving this to a separate interception layer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces fine-grained scope validation to the SCIM layer, specifically enhancing access control for bulk operations. If the request is a bulk operation, the server checks whether the user has the required scope. If the scope is not available, a Forbidden exception is thrown.
Related PR: