Skip to content

Add Fine-Grained Scope Validation for SCIM2 Bulk API#649

Draft
asha15 wants to merge 5 commits into
wso2-extensions:archive_IS-7.3from
asha15:fineGrainedScope
Draft

Add Fine-Grained Scope Validation for SCIM2 Bulk API#649
asha15 wants to merge 5 commits into
wso2-extensions:archive_IS-7.3from
asha15:fineGrainedScope

Conversation

@asha15

@asha15 asha15 commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

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:

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.");
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to get the scopes from privileged carbon context.

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"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get these from resource access control file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check kernel

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.");
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about moving this to a separate interception layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants