Skip to content

Commit

Permalink
reverted changes to GetAuthorizedActionsHandler. Added BuiltInRole of…
Browse files Browse the repository at this point in the history
… CAN_EDIT_REGULAR
  • Loading branch information
soimugeo committed Jul 2, 2024
1 parent 3fa574d commit d00b5ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public enum BuiltInRole {

CAN_EDIT(PROJECT_EDITOR, CAN_COMMENT),

CAN_EDIT_REGULAR(REGULAR_PROJECT_EDITOR, CAN_COMMENT),

CAN_MANAGE(CAN_EDIT, PROJECT_MANAGER, ISSUE_MANAGER)

;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,7 @@ public Mono<GetAuthorizedActionsResponse> handleRequest(GetAuthorizedActionsRequ
/*
ToDo: Understand why we need this if else here
*/
// if(request.resource().isApplication()) {
// try {
// List<RoleId> roleIds = tokenValidator.getTokenClaims(executionContext.jwt()).stream()
// .map(RoleId::new)
// .toList();
// Set<ActionId> actions = new HashSet<>(roleOracle.getActionsAssociatedToRoles(roleIds));
// return Mono.just(new GetAuthorizedActionsResponse(request.resource(),
// request.subject(),
// actions));
//
// } catch (VerificationException e) {
// throw new RuntimeException(e);
// }
// }else {
// var actionClosure = accessManager.getActionClosure(request.subject(),
// request.resource());
// return Mono.just(new GetAuthorizedActionsResponse(request.resource(),
// request.subject(),
// actionClosure));
// }

if(request.resource().isApplication()) {
try {
List<RoleId> roleIds = tokenValidator.getTokenClaims(executionContext.jwt()).stream()
.map(RoleId::new)
Expand All @@ -82,5 +62,12 @@ public Mono<GetAuthorizedActionsResponse> handleRequest(GetAuthorizedActionsRequ
} catch (VerificationException e) {
throw new RuntimeException(e);
}
}else {
var actionClosure = accessManager.getActionClosure(request.subject(),
request.resource());
return Mono.just(new GetAuthorizedActionsResponse(request.resource(),
request.subject(),
actionClosure));
}
}
}

0 comments on commit d00b5ec

Please sign in to comment.