@@ -669,12 +669,12 @@ public void search_staticIndices_systemIndex_alias() throws Exception {
669669 assertThat (httpResponse , isForbidden ());
670670 }
671671 } else if (clusterConfig == ClusterConfig .LEGACY_PRIVILEGES_EVALUATION_SYSTEM_INDEX_PERMISSION ) {
672- assertThat (
673- httpResponse ,
674- containsExactly (system_index_plugin ).at ("hits.hits[*]._index" )
675- .reducedBy (user .indexMatcher ("read" ))
676- .whenEmpty (isForbidden ())
677- );
672+ assertThat (
673+ httpResponse ,
674+ containsExactly (system_index_plugin ).at ("hits.hits[*]._index" )
675+ .reducedBy (user .indexMatcher ("read" ))
676+ .whenEmpty (isForbidden ())
677+ );
678678 } else {
679679 if (user .indexMatcher ("read" ).covers (alias_with_system_index )) {
680680 assertThat (httpResponse , isOk ());
@@ -867,7 +867,7 @@ public void search_alias_pattern_negation() throws Exception {
867867 .reducedBy (user .indexMatcher ("read" ))
868868 .whenEmpty (clusterConfig .allowsEmptyResultSets ? isOk () : isForbidden ())
869869 );
870- /*
870+ /*
871871 if (user != LIMITED_USER_NONE) {
872872 if (clusterConfig.systemIndexPrivilegeEnabled) {
873873 // If the system index privilege is enabled, we might also see the system_index_plugin index (being included via the
@@ -1448,7 +1448,7 @@ public void getAlias_all() throws Exception {
14481448 } else {
14491449 assertThat (
14501450 httpResponse ,
1451- containsExactly (alias_ab1 , alias_c1 ).at ("$.*.aliases.keys()" )
1451+ containsExactly (alias_ab1 , alias_c1 , alias_with_system_index ).at ("$.*.aliases.keys()" )
14521452 .reducedBy (user .indexMatcher ("get_alias" ))
14531453 .whenEmpty (clusterConfig .allowsEmptyResultSets ? isOk () : isForbidden ())
14541454 );
@@ -1795,13 +1795,16 @@ public void pit_list_all() throws Exception {
17951795 try (TestRestClient restClient = cluster .getRestClient (user )) {
17961796 TestRestClient .HttpResponse httpResponse = restClient .get ("_search/point_in_time/_all" );
17971797
1798- // At the moment, it is sufficient to have any privileges for any existing index to use the _all API
1799- // This is clearly a bug; yet, not a severe issue, as we do not have really sensitive things available here
1800- if (user != LIMITED_USER_NONE && user != LIMITED_USER_OTHER_PRIVILEGES ) {
1801- assertThat (httpResponse , isOk ());
1802- } else {
1803- assertThat (httpResponse , isForbidden ());
1804- }
1798+ // At the moment, it is sufficient to have any privileges for any existing index to use the _all API
1799+ // This is clearly a bug; yet, not a severe issue, as we do not have really sensitive things available here.
1800+ // This is caused by the following line which makes PrivilegesEvaluator believe it could reduce the indices
1801+ // to authorized indices, even though it actually could not:
1802+ // https://github.com/opensearch-project/security/blob/aee54a8ca2a6cc596cb1e490be1e9fa240286246/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java#L824-L825
1803+ if (user != LIMITED_USER_NONE && user != LIMITED_USER_OTHER_PRIVILEGES ) {
1804+ assertThat (httpResponse , isOk ());
1805+ } else {
1806+ assertThat (httpResponse , isForbidden ());
1807+ }
18051808 } finally {
18061809 deletePit (indexA1pitId );
18071810 }
@@ -1848,24 +1851,11 @@ public void pit_catSegments_all() throws Exception {
18481851 try (TestRestClient restClient = cluster .getRestClient (user )) {
18491852 TestRestClient .HttpResponse httpResponse = restClient .get ("_cat/pit_segments/_all" );
18501853
1851- if (clusterConfig == ClusterConfig .LEGACY_PRIVILEGES_EVALUATION_SYSTEM_INDEX_PERMISSION ) {
1852- // Once again, the system index privilege code makes it impossible to use this action without super admin privileges
1853- if (user == SUPER_UNLIMITED_USER ) {
1854- assertThat (httpResponse , isOk ());
1855- } else {
1856- assertThat (httpResponse , isForbidden ());
1857- }
1854+ // The user needs to have the privilege for all indices. If it is only granted for a subset of indices, this will be forbidden.
1855+ if (user == UNLIMITED_USER || user == SUPER_UNLIMITED_USER ) {
1856+ assertThat (httpResponse , isOk ());
18581857 } else {
1859- // The behavior in legacy privilege evaluation and new privilege evaluation actually differs, even though we do not observe
1860- // here a difference:
1861- // - Legacy: the user needs to have the privilege for all indices. If it is only granted for a subset of indices, this will
1862- // be forbidden.
1863- // - New: this is now a separate cluster privilege, the users below are the users with full cluster privileges
1864- if (user == UNLIMITED_USER || user == SUPER_UNLIMITED_USER ) {
1865- assertThat (httpResponse , isOk ());
1866- } else {
1867- assertThat (httpResponse , isForbidden ());
1868- }
1858+ assertThat (httpResponse , isForbidden ());
18691859 }
18701860 } finally {
18711861 deletePit (indexA1pitId );
0 commit comments