41
41
import org .opensearch .cluster .metadata .IndexNameExpressionResolver ;
42
42
import org .opensearch .cluster .service .ClusterService ;
43
43
import org .opensearch .common .settings .Settings ;
44
- import org .opensearch .indices .SystemIndexRegistry ;
45
44
import org .opensearch .security .auditlog .AuditLog ;
46
45
import org .opensearch .security .resolver .IndexResolverReplacer ;
47
46
import org .opensearch .security .resolver .IndexResolverReplacer .Resolved ;
57
56
* - The term `protected system indices` used here translates to system indices
58
57
* which have an added layer of security and cannot be accessed by anyone except Super Admin
59
58
*/
60
- public class SystemIndexAccessEvaluator {
59
+ public class SecurityIndexAccessEvaluator {
61
60
62
61
Logger log = LogManager .getLogger (this .getClass ());
63
62
@@ -73,7 +72,7 @@ public class SystemIndexAccessEvaluator {
73
72
private final boolean isSystemIndexEnabled ;
74
73
private final boolean isSystemIndexPermissionEnabled ;
75
74
76
- public SystemIndexAccessEvaluator (final Settings settings , AuditLog auditLog , IndexResolverReplacer irr ) {
75
+ public SecurityIndexAccessEvaluator (final Settings settings , AuditLog auditLog , IndexResolverReplacer irr ) {
77
76
this .securityIndex = settings .get (
78
77
ConfigConstants .SECURITY_CONFIG_INDEX_NAME ,
79
78
ConfigConstants .OPENDISTRO_SECURITY_DEFAULT_CONFIG_INDEX
@@ -84,7 +83,6 @@ public SystemIndexAccessEvaluator(final Settings settings, AuditLog auditLog, In
84
83
this .systemIndexMatcher = WildcardMatcher .from (
85
84
settings .getAsList (ConfigConstants .SECURITY_SYSTEM_INDICES_KEY , ConfigConstants .SECURITY_SYSTEM_INDICES_DEFAULT )
86
85
);
87
-
88
86
this .superAdminAccessOnlyIndexMatcher = WildcardMatcher .from (this .securityIndex );
89
87
this .isSystemIndexEnabled = settings .getAsBoolean (
90
88
ConfigConstants .SECURITY_SYSTEM_INDICES_ENABLED_KEY ,
@@ -170,16 +168,15 @@ private boolean requestContainsAnySystemIndices(final Resolved requestedResolved
170
168
* It will always return security index if it is present in the request, as security index is protected regardless
171
169
* of feature being enabled or disabled
172
170
* @param requestedResolved request which contains indices to be matched against system indices
173
- * @return the set of protected system indices present in the request
171
+ * @return the list of protected system indices present in the request
174
172
*/
175
- private Set <String > getAllSystemIndices (final Resolved requestedResolved ) {
176
- final Set <String > systemIndices = requestedResolved .getAllIndices ()
173
+ private List <String > getAllSystemIndices (final Resolved requestedResolved ) {
174
+ final List <String > systemIndices = requestedResolved .getAllIndices ()
177
175
.stream ()
178
176
.filter (securityIndex ::equals )
179
- .collect (Collectors .toSet ());
177
+ .collect (Collectors .toList ());
180
178
if (isSystemIndexEnabled ) {
181
179
systemIndices .addAll (systemIndexMatcher .getMatchAny (requestedResolved .getAllIndices (), Collectors .toList ()));
182
- systemIndices .addAll (SystemIndexRegistry .matchesSystemIndexPattern (requestedResolved .getAllIndices ().toArray (String []::new )));
183
180
}
184
181
return systemIndices ;
185
182
}
@@ -213,7 +210,7 @@ private List<String> getAllProtectedSystemIndices(final Resolved requestedResolv
213
210
private boolean requestContainsAnyRegularIndices (final Resolved requestedResolved ) {
214
211
Set <String > allIndices = requestedResolved .getAllIndices ();
215
212
216
- Set <String > allSystemIndices = getAllSystemIndices (requestedResolved );
213
+ List <String > allSystemIndices = getAllSystemIndices (requestedResolved );
217
214
List <String > allProtectedSystemIndices = getAllProtectedSystemIndices (requestedResolved );
218
215
219
216
return allIndices .stream ().anyMatch (index -> !allSystemIndices .contains (index ) && !allProtectedSystemIndices .contains (index ));
0 commit comments