Skip to content

Commit b7fc0ac

Browse files
authored
Fix privileges for GetRollupIndexCapabilities API (#75614)
In addition to read, access to this API is now also granted by view_index_metadata and manage. Resolves: #74779
1 parent 36ee1e1 commit b7fc0ac

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

docs/reference/rollup/apis/rollup-index-caps.asciidoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ experimental[]
1919
[[rollup-get-rollup-index-caps-prereqs]]
2020
==== {api-prereq-title}
2121

22-
* If the {es} {security-features} are enabled, you must have the `read` index
23-
privilege on the index that stores the rollup results. For more information, see
22+
* If the {es} {security-features} are enabled, you must have any of the `read`,
23+
`view_index_metadata`, or `manage` <<privileges-list-indices,index privilege>>
24+
on the index that stores the rollup results. For more information, see
2425
<<security-privileges>>.
2526

2627
[[rollup-get-rollup-index-caps-desc]]
@@ -46,7 +47,7 @@ Wildcard (`*`) expressions are supported.
4647
==== {api-examples-title}
4748

4849
Imagine we have an index named `sensor-1` full of raw data. We know that the
49-
data will grow over time, so there will be a `sensor-2`, `sensor-3`, etc.
50+
data will grow over time, so there will be a `sensor-2`, `sensor-3`, etc.
5051
Let's create a {rollup-job} that stores its data in `sensor_rollup`:
5152

5253
[source,console]
@@ -145,7 +146,7 @@ original rollup configuration, but formatted differently. First, there are some
145146
house-keeping details: the {rollup-job} ID, the index that holds the rolled data,
146147
the index pattern that the job was targeting.
147148

148-
Next it shows a list of fields that contain data eligible for rollup searches.
149+
Next it shows a list of fields that contain data eligible for rollup searches.
149150
Here we see four fields: `node`, `temperature`, `timestamp` and `voltage`. Each
150151
of these fields list the aggregations that are possible. For example, you can
151152
use a min, max, or sum aggregation on the `temperature` field, but only a
@@ -164,4 +165,3 @@ instead of explicit indices:
164165
GET /*_rollup/_rollup/data
165166
--------------------------------------------------
166167
// TEST[continued]
167-

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
3434
import org.elasticsearch.xpack.core.ccr.action.UnfollowAction;
3535
import org.elasticsearch.xpack.core.ilm.action.ExplainLifecycleAction;
36+
import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
3637
import org.elasticsearch.xpack.core.security.support.Automatons;
3738

3839
import java.util.Arrays;
@@ -66,14 +67,15 @@ public final class IndexPrivilege extends Privilege {
6667
private static final Automaton WRITE_AUTOMATON = patterns("indices:data/write/*", AutoPutMappingAction.NAME);
6768
private static final Automaton MONITOR_AUTOMATON = patterns("indices:monitor/*");
6869
private static final Automaton MANAGE_AUTOMATON =
69-
unionAndMinimize(Arrays.asList(MONITOR_AUTOMATON, patterns("indices:admin/*", FieldCapabilitiesAction.NAME + "*")));
70+
unionAndMinimize(Arrays.asList(MONITOR_AUTOMATON, patterns("indices:admin/*", FieldCapabilitiesAction.NAME + "*",
71+
GetRollupIndexCapsAction.NAME + "*")));
7072
private static final Automaton CREATE_INDEX_AUTOMATON = patterns(CreateIndexAction.NAME, AutoCreateAction.NAME,
7173
CreateDataStreamAction.NAME);
7274
private static final Automaton DELETE_INDEX_AUTOMATON = patterns(DeleteIndexAction.NAME, DeleteDataStreamAction.NAME);
7375
private static final Automaton VIEW_METADATA_AUTOMATON = patterns(GetAliasesAction.NAME, GetIndexAction.NAME,
7476
GetFieldMappingsAction.NAME + "*", GetMappingsAction.NAME, ClusterSearchShardsAction.NAME, ValidateQueryAction.NAME + "*",
7577
GetSettingsAction.NAME, ExplainLifecycleAction.NAME, GetDataStreamAction.NAME, ResolveIndexAction.NAME,
76-
FieldCapabilitiesAction.NAME + "*");
78+
FieldCapabilitiesAction.NAME + "*", GetRollupIndexCapsAction.NAME + "*");
7779
private static final Automaton MANAGE_FOLLOW_INDEX_AUTOMATON = patterns(PutFollowAction.NAME, UnfollowAction.NAME,
7880
CloseIndexAction.NAME + "*", PromoteDataStreamAction.NAME, RolloverAction.NAME);
7981
private static final Automaton MANAGE_LEADER_INDEX_AUTOMATON = patterns(ForgetFollowerAction.NAME + "*");

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilegeTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import org.elasticsearch.action.update.UpdateAction;
1717
import org.elasticsearch.common.util.iterable.Iterables;
1818
import org.elasticsearch.test.ESTestCase;
19+
import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction;
1920

21+
import java.util.Collection;
2022
import java.util.List;
2123
import java.util.Set;
2224

@@ -60,4 +62,9 @@ public void testFindPrivilegesThatGrant() {
6062
assertThat(findPrivilegesThatGrant(ShrinkAction.NAME), equalTo(List.of("manage", "all")));
6163
}
6264

65+
public void testPrivilegesForRollupFieldCapsAction() {
66+
final Collection<String> privileges = findPrivilegesThatGrant(GetRollupIndexCapsAction.NAME);
67+
assertThat(Set.copyOf(privileges), equalTo(Set.of("read", "view_index_metadata", "manage", "all")));
68+
}
69+
6370
}

0 commit comments

Comments
 (0)