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

[2.x] Optimize privilege evaluation for index permissions across '*' index pattern (i.e. all_access role) #4926

Merged
Changes from 2 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 @@ -79,6 +79,7 @@ public class ConfigModelV7 extends ConfigModel {
private RoleMappingHolder roleMappingHolder;
private SecurityDynamicConfiguration<RoleV7> roles;
private SecurityDynamicConfiguration<TenantV7> tenants;
private final static Set<String> ALL_INDICES = Set.of("*");

public ConfigModelV7(
SecurityDynamicConfiguration<RoleV7> roles,
Expand Down Expand Up @@ -1000,12 +1001,15 @@ private static boolean impliesTypePerm(
if (resolved.isLocalAll()) {
indexMatcherAndPermissions = ipatterns.stream()
.filter(indexPattern -> "*".equals(indexPattern.getUnresolvedIndexPattern(user)))
.map(p -> new IndexMatcherAndPermissions(p.attemptResolveIndexNames(user, resolver, cs), p.perms))
.map(p -> new IndexMatcherAndPermissions(ALL_INDICES, p.perms))
.toArray(IndexMatcherAndPermissions[]::new);
} else {
indexMatcherAndPermissions = ipatterns.stream()
.map(p -> new IndexMatcherAndPermissions(p.attemptResolveIndexNames(user, resolver, cs), p.perms))
.toArray(IndexMatcherAndPermissions[]::new);
indexMatcherAndPermissions = ipatterns.stream().map(p -> {
if ("*".equals(p.getUnresolvedIndexPattern(user))) {
return new IndexMatcherAndPermissions(ALL_INDICES, p.perms);
}
return new IndexMatcherAndPermissions(p.attemptResolveIndexNames(user, resolver, cs), p.perms);
}).toArray(IndexMatcherAndPermissions[]::new);
}
return resolvedRequestedIndices.stream()
.allMatch(
Expand Down
Loading