Skip to content

Commit 9f9fddc

Browse files
authored
fix duplicate check (#2183)
Signed-off-by: Hailong Cui <ihailong@amazon.com>
1 parent ba9d82e commit 9f9fddc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map.Entry;
2828
import java.util.Objects;
2929
import java.util.Set;
30+
import java.util.TreeSet;
3031
import java.util.concurrent.Callable;
3132
import java.util.concurrent.ExecutionException;
3233
import java.util.concurrent.ExecutorService;
@@ -1116,21 +1117,21 @@ public Map<String, Boolean> mapTenants(final User user, Set<String> roles) {
11161117

11171118
if (rw || !result.containsKey(tenant)) { //RW outperforms RO
11181119

1119-
// We want to make sure that we add a tenant that exissts
1120+
// We want to make sure that we add a tenant that exists
11201121
// Indeed, because we don't have control over what will be
11211122
// passed on as values of users' attributes, we have to make
11221123
// sure that we don't allow them to select tenants that do not exist.
1123-
if(ConfigModelV7.this.tenants.getCEntries().keySet().contains(tenant)) {
1124+
if(ConfigModelV7.this.tenants.getCEntries().containsKey(tenant)) {
11241125
result.put(tenant, rw);
11251126
}
11261127
}
11271128
});
1128-
1129+
1130+
Set<String> _roles = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
1131+
_roles.addAll(roles);
11291132
if(!result.containsKey("global_tenant") && (
1130-
roles.contains("kibana_user")
1131-
|| roles.contains("kibana_user")
1132-
|| roles.contains("all_access")
1133-
|| roles.contains("ALL_ACCESS")
1133+
_roles.contains("kibana_user")
1134+
|| _roles.contains("all_access")
11341135
)) {
11351136
result.put("global_tenant", true);
11361137
}

0 commit comments

Comments
 (0)