Skip to content

Add an endpoint filtering the elements a user can access - #267

Open
flomillot wants to merge 2 commits into
mainfrom
feat/batch-element-permissions
Open

Add an endpoint filtering the elements a user can access#267
flomillot wants to merge 2 commits into
mainfrom
feat/batch-element-permissions

Conversation

@flomillot

@flomillot flomillot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

The user groups are now resolved once for the whole batch rather than once per element. The unitary path is unchanged.

Consumed by gridsuite/explore-server#209.

The existing /elements/authorized answers all-or-nothing: a single
forbidden element denies the whole request. Resolving the permissions of
several independent elements therefore took one call each.

The new /elements/permission returns which of the given elements the user
may access, leaving out the forbidden and the unknown ones. The user
groups are resolved once for the whole batch instead of once per element.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 75b2e56c-f0f4-46a0-86d1-a9ef0c596240


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

return ResponseEntity.ok().build();
}

@GetMapping(value = "/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE)

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.

@GetMapping(value = "/elements/accessible", produces = MediaType.APPLICATION_JSON_VALUE)

}

@GetMapping(value = "/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get, among the given elements, the ones the user can access with the given permission")

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.

Filter the given elements to the ones the user has the given permission on

@GetMapping(value = "/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get, among the given elements, the ones the user can access with the given permission")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The uuids of the accessible elements"),

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.

The uuids of the given elements the user has the permission on

return hasElementPermission(userId, uuid, permissionType, () -> getUserGroupIds(userId));
}

private boolean hasElementPermission(String userId, UUID uuid, PermissionType permissionType, Supplier<List<UUID>> userGroupIds) {

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.

userGroupIdsSupplier


//Finally check group permission
return userAdminService.getUserGroups(userId)
return userGroupIds.get()

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.

userGroupIdsSupplier.get()

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