Replace the element permission check with a batch endpoint - #209
Replace the element permission check with a batch endpoint#209flomillot wants to merge 2 commits into
Conversation
HEAD /elements/{uuid} answered a single element with a 200 or a 403. The
new GET /elements/permission takes a list of element uuids and returns the
ones the user has the given right on, so a client resolving several
elements no longer needs one call per element.
Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
| directoryService.checkPermission(List.of(elementUuid), null, userId, permission); | ||
| return ResponseEntity.ok().build(); | ||
| public ResponseEntity<List<UUID>> getAccessibleElements(@RequestParam("ids") List<UUID> elementUuids, | ||
| @RequestParam(name = "accessType") PermissionType permission, |
There was a problem hiding this comment.
@RequestParam(name = "accessType") PermissionType permissionType,
| @RequestParam(name = "accessType") PermissionType permission, | ||
| @RequestHeader(QUERY_PARAM_USER_ID) String userId) { | ||
| return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON) | ||
| .body(directoryService.getAccessibleElements(elementUuids, userId, permission)); |
There was a problem hiding this comment.
.body(directoryService.getAccessibleElements(elementUuids, userId, permissionType));
|
|
||
| @GetMapping(value = "/explore/elements/{elementUuid}") | ||
| @Operation(summary = "Check if user has a given right on a directory, or a single element by checking its parent") | ||
| @GetMapping(value = "/explore/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE) |
There was a problem hiding this comment.
@GetMapping(value = "/explore/elements/accessible"
| @GetMapping(value = "/explore/elements/{elementUuid}") | ||
| @Operation(summary = "Check if user has a given right on a directory, or a single element by checking its parent") | ||
| @GetMapping(value = "/explore/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @Operation(summary = "Get, among the given elements, the ones the user has the given right on, " |
There was a problem hiding this comment.
@operation(summary = "Filter the given elements to the ones the user has the given permission on, "
+ "a directory is checked on itself, any other element on its parent directory")
There was a problem hiding this comment.
the , instead of and is not correct but OK for the rest
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "The user has the right on the element"), | ||
| @ApiResponse(responseCode = "204", description = "The user has not the right on the element"), | ||
| @ApiResponse(responseCode = "200", description = "The uuids of the elements the user has the right on"), |
There was a problem hiding this comment.
description = "The uuids of the given elements the user has the permission on"
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.add(HEADER_USER_ID, userId); | ||
|
|
||
| String path = UriComponentsBuilder.fromPath(ELEMENTS_SERVER_ROOT_PATH + "/permission") |
There was a problem hiding this comment.
String path = UriComponentsBuilder.fromPath(ELEMENTS_SERVER_ROOT_PATH + "/accessible")
The endpoint returns elements, not a permission, which its name now reflects, along with the path it calls on directory-server. The controller parameter is renamed permissionType, as the service it delegates to already named it, and the operation and response descriptions are reworded accordingly. Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
|



Depends on gridsuite/directory-server#267.
HEAD /explore/elements/{uuid}?permission=…answers a single element with a 200 or a 403, so a client resolving several elements needs one call per element.It is replaced by
GET /explore/elements/accessible?ids=…&accessType=…, which returns the uuids the user has the given right on, the forbidden and the unknown ones being left out. It delegates to the directory-server endpoint added in the PR above.