Skip to content

Commit 49f9c4c

Browse files
committed
Clean up
1 parent f7e1690 commit 49f9c4c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ public Collection<String> resolveConcreteIndices(ProjectMetadata metadata) {
517517
public boolean canHaveBackingIndices() {
518518
return indexAbstraction != null && indexAbstraction.getType() != IndexAbstraction.Type.CONCRETE_INDEX;
519519
}
520+
521+
public String nameCombinedWithSelector() {
522+
if (IndexComponentSelector.FAILURES.equals(selector)) {
523+
return IndexNameExpressionResolver.combineSelector(name, selector);
524+
}
525+
return name;
526+
}
520527
}
521528

522529
/**
@@ -539,16 +546,16 @@ public IndicesAccessControl authorize(
539546
int totalResourceCount = 0;
540547
Map<String, IndexAbstraction> lookup = metadata.getIndicesLookup();
541548
for (String indexOrAlias : requestedIndicesOrAliases) {
542-
String originalIndexOrAlias = indexOrAlias;
543-
// Remove any selectors from abstraction name, but include it in the map key if it's ::failures. We need to do this to
544-
// disambiguate between data streams and their failure stores.
549+
// Remove any selectors from abstraction name.
545550
Tuple<String, String> expressionAndSelector = IndexNameExpressionResolver.splitSelectorExpression(indexOrAlias);
546551
indexOrAlias = expressionAndSelector.v1();
547552
IndexComponentSelector selector = expressionAndSelector.v2() == null
548553
? null
549554
: IndexComponentSelector.getByKey(expressionAndSelector.v2());
550555
final IndexResource resource = new IndexResource(indexOrAlias, lookup.get(indexOrAlias), selector);
551-
resources.put(IndexComponentSelector.FAILURES.equals(selector) ? originalIndexOrAlias : indexOrAlias, resource);
556+
// We can't use resource.name here because we may be accessing a data stream _and_ its failure store,
557+
// where the selector-free name is the same for both and thus ambiguous.
558+
resources.put(resource.nameCombinedWithSelector(), resource);
552559
totalResourceCount += resource.size(lookup);
553560
}
554561

0 commit comments

Comments
 (0)