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

Fix: retrieve org if no org filter #201

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
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 @@ -208,12 +208,18 @@ private Map<String, List<String>> listRoles(Set<Role> roles, String orgFilter) {
// (the empty key is for cross org roles such as "role/iam/admin")
roles.forEach(r -> {
String orgName = r.getOrganisation().map(Organisation::getName).orElse(NO_ORG);
// if no orgFilter, we only keep the roles associated to "no org"
if ((orgFilter == null && orgName.equals(NO_ORG))
|| orgName.equals(orgFilter)) {
// if no orgFilter, we keep all the roles
if(orgFilter == null){
List<String> roleList = Optional.ofNullable(orgRoles.get(orgName)).orElseGet(ArrayList::new);
roleList.add(r.getName());
orgRoles.put(orgName, roleList);
}else{
// if orgFilter, we add only the roles of the org or no org
if(orgName.equals(orgFilter) || orgName.equals(NO_ORG)){
List<String> roleList = Optional.ofNullable(orgRoles.get(orgName)).orElseGet(ArrayList::new);
roleList.add(r.getName());
orgRoles.put(orgName, roleList);
}
}
});
// manually add "group/public" which is given to everybody
Expand Down Expand Up @@ -863,10 +869,14 @@ private Set<String> listPermissions(Set<Role> roles, String orgFilter) {
Set<Permission> permissions = new HashSet<>();
roles.forEach(r -> {
String orgName = r.getOrganisation().map(Organisation::getName).orElse(NO_ORG);
// if no orgFilter, we only keep the permissions associated to "no org"
if ((orgFilter == null && orgName.equals(NO_ORG))
|| orgName.equals(orgFilter)) {
// if no orgFilter, we add all the permissions
if(orgFilter == null){
permissions.addAll(r.getPermissions());
}else{
// if orgFilter, we add only the permissions of the org or no org
if(orgName.equals(orgFilter) || orgName.equals(NO_ORG)){
permissions.addAll(r.getPermissions());
}
}
});

Expand Down
Loading