Skip to content

Commit

Permalink
feat(serviceAccounts): enable loading full service account details fo…
Browse files Browse the repository at this point in the history
…r each users serviceAccount (#629)

adds an expand query parameter to the /auth/:userId/serviceAccounts endpoint that returns each
serviceAccount as a userPermission to allow for contextual filtering

This will enable an endpoint in gate to filter user service accounts by application when populating
the run as user dropdown in the UI to only include service accounts relevant for the application
being configured
  • Loading branch information
cfieber committed Apr 2, 2020
1 parent 95d2e76 commit 27e720b
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,18 @@ public Application.View getUserApplication(
}

@RequestMapping(value = "/{userId:.+}/serviceAccounts", method = RequestMethod.GET)
public Set<ServiceAccount.View> getServiceAccounts(@PathVariable String userId) {
return new HashSet<>(getUserPermissionView(userId).getServiceAccounts());
public Set<? extends Viewable.BaseView> getServiceAccounts(
@PathVariable String userId,
@RequestParam(name = "expand", defaultValue = "false") boolean expand) {
Set<ServiceAccount.View> serviceAccounts = getUserPermissionView(userId).getServiceAccounts();
if (!expand) {
return serviceAccounts;
}

return serviceAccounts.stream()
.map(ServiceAccount.View::getName)
.map(this::getUserPermissionView)
.collect(Collectors.toSet());
}

@RequestMapping(
Expand Down

0 comments on commit 27e720b

Please sign in to comment.