Skip to content
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

Replaced MEASUREMENT.CREATE permissions #454

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public NotificationStateEventController(
this.notificationStateEventService = notificationStateEventService;
}

@Authorized(permission = AuthPermissions.CREATE, entity = AuthEntities.MEASUREMENT)
@Authorized(permission = AuthPermissions.READ, entity = AuthEntities.PROJECT)
@GetMapping(
value =
"/"
Expand All @@ -64,8 +64,8 @@ public ResponseEntity<List<NotificationStateEventDto>> getNotificationStateEvent
}

@Authorized(
permission = AuthPermissions.CREATE,
entity = AuthEntities.MEASUREMENT,
permission = AuthPermissions.READ,
entity = AuthEntities.SUBJECT,
permissionOn = PermissionOn.SUBJECT)
@GetMapping(
value =
Expand Down Expand Up @@ -93,8 +93,8 @@ public ResponseEntity<List<NotificationStateEventDto>> getNotificationStateEvent
}

@Authorized(
permission = AuthPermissions.CREATE,
entity = AuthEntities.MEASUREMENT,
permission = AuthPermissions.UPDATE,
entity = AuthEntities.SUBJECT,
permissionOn = PermissionOn.SUBJECT)
@PostMapping(
value =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public ResponseEntity<ProjectDto> addProject(
* org.radarbase.appserver.exception.NotFoundException} if project was not found.
*/
@Authorized(
permission = AuthPermissions.CREATE,
entity = AuthEntities.MEASUREMENT,
permission = AuthPermissions.UPDATE,
entity = AuthEntities.PROJECT,
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be permission = AuthPermissions.READ and inside the function we can check if the user has permission on the project like like: https://github.com/RADAR-base/RADAR-Appserver/pull/454/files#diff-1e80e358e3364d4b93b1aa06498dedf1686f827ff9bca66eb31b0164b72d3ca8R170

Because I don't think aRMT has PROJECT.UPDATE permissions. What do you think @yatharthranjan?

Copy link
Member

Choose a reason for hiding this comment

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

I think we usually check SUBJECT.UPDATE on the PROJECT (since even the projects in appserver are created by participant tokens)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi, I've updated the permissions to SUBJECT.UPDATE and I also updated the authorization code inside the function as Pauline suggested. Please let me know if any changes are needed.

permissionOn = PermissionOn.PROJECT)
@PutMapping(
value = "/" + PathsUtil.PROJECT_PATH + "/" + PathsUtil.PROJECT_ID_CONSTANT,
Expand Down Expand Up @@ -160,7 +160,7 @@ public ResponseEntity<ProjectDtos> getAllProjects(HttpServletRequest request) {
}

// TODO think about plain authorized
@Authorized(permission = AuthPermissions.CREATE, entity = AuthEntities.MEASUREMENT)
@Authorized(permission = AuthPermissions.READ, entity = AuthEntities.PROJECT)
@GetMapping("/" + PathsUtil.PROJECT_PATH + "/project")
public ResponseEntity<ProjectDto> getProjectsUsingId(
HttpServletRequest request, @Valid @PathParam("id") Long id) {
Expand All @@ -169,8 +169,8 @@ public ResponseEntity<ProjectDto> getProjectsUsingId(
RadarToken token = (RadarToken) request.getAttribute(AuthAspect.TOKEN_KEY);
if (authorization.hasPermission(
token,
AuthPermissions.CREATE,
AuthEntities.MEASUREMENT,
AuthPermissions.READ,
AuthEntities.PROJECT,
PermissionOn.PROJECT,
projectDto.getProjectId(),
null,
Expand Down
Loading