21
21
import java .util .function .Supplier ;
22
22
import java .util .stream .Collectors ;
23
23
24
- import com .google .common .base .Strings ;
25
24
import com .google .common .collect .ImmutableMap ;
26
25
import com .google .common .collect .ImmutableSet ;
27
26
import org .apache .commons .collections4 .CollectionUtils ;
@@ -64,29 +63,13 @@ public class ActionPrivileges extends ClusterStateMetadataDependentPrivileges {
64
63
* This settings defaults to 10 MB. This is a generous limit. Experiments have shown that an example setup with
65
64
* 10,000 indices and 1,000 roles requires about 1 MB of heap. 100,000 indices and 100 roles require about 9 MB of heap.
66
65
* (Of course, these numbers can vary widely based on the actual role configuration).
67
- * <p>
68
- * The setting plugins.security.privileges_evaluation.precomputed_privileges.include_indices can be used to control
69
- * for which indices the precomputed privileges shall be created. This allows to lower the heap utilization.
70
66
*/
71
67
public static Setting <ByteSizeValue > PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE = Setting .memorySizeSetting (
72
68
"plugins.security.privileges_evaluation.precomputed_privileges.max_heap_size" ,
73
69
new ByteSizeValue (10 , ByteSizeUnit .MB ),
74
70
Setting .Property .NodeScope
75
71
);
76
72
77
- /**
78
- * Determines the indices which shall be included in the precomputed index privileges. Included indices get
79
- * the fasted privilege evaluation.
80
- * <p>
81
- * You can use patterns like "index_*".
82
- * <p>
83
- * Defaults to all indices.
84
- */
85
- public static Setting <String > PRECOMPUTED_PRIVILEGES_INCLUDE_INDICES = Setting .simpleString (
86
- "plugins.security.privileges_evaluation.precomputed_privileges.include_indices" ,
87
- Setting .Property .NodeScope
88
- );
89
-
90
73
private static final Logger log = LogManager .getLogger (ActionPrivileges .class );
91
74
92
75
private final ClusterPrivileges cluster ;
@@ -97,7 +80,6 @@ public class ActionPrivileges extends ClusterStateMetadataDependentPrivileges {
97
80
private final ImmutableSet <String > wellKnownIndexActions ;
98
81
private final Supplier <Map <String , IndexAbstraction >> indexMetadataSupplier ;
99
82
private final ByteSizeValue statefulIndexMaxHeapSize ;
100
- private final WildcardMatcher statefulIndexIncludeIndices ;
101
83
102
84
private final AtomicReference <StatefulIndexPrivileges > statefulIndex = new AtomicReference <>();
103
85
@@ -118,10 +100,6 @@ public ActionPrivileges(
118
100
this .wellKnownIndexActions = wellKnownIndexActions ;
119
101
this .indexMetadataSupplier = indexMetadataSupplier ;
120
102
this .statefulIndexMaxHeapSize = PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE .get (settings );
121
- String statefulIndexIncludeIndices = PRECOMPUTED_PRIVILEGES_INCLUDE_INDICES .get (settings );
122
- this .statefulIndexIncludeIndices = Strings .isNullOrEmpty (statefulIndexIncludeIndices )
123
- ? null
124
- : WildcardMatcher .from (statefulIndexIncludeIndices );
125
103
}
126
104
127
105
public ActionPrivileges (
@@ -241,7 +219,7 @@ public PrivilegesEvaluatorResponse hasExplicitIndexPrivilege(
241
219
void updateStatefulIndexPrivileges (Map <String , IndexAbstraction > indices , long metadataVersion ) {
242
220
StatefulIndexPrivileges statefulIndex = this .statefulIndex .get ();
243
221
244
- indices = StatefulIndexPrivileges .relevantOnly (indices , statefulIndexIncludeIndices );
222
+ indices = StatefulIndexPrivileges .relevantOnly (indices );
245
223
246
224
if (statefulIndex == null || !statefulIndex .indices .equals (indices )) {
247
225
long start = System .currentTimeMillis ();
@@ -1004,10 +982,9 @@ static class StatefulIndexPrivileges {
1004
982
.getEstimatedByteSize () > statefulIndexMaxHeapSize .getBytes ()) {
1005
983
log .info (
1006
984
"Size of precomputed index privileges exceeds configured limit ({}). Using capped data structure."
1007
- + "This might lead to slightly lower performance during privilege evaluation. Consider raising {} or limiting the performance critical indices using {} ." ,
985
+ + "This might lead to slightly lower performance during privilege evaluation. Consider raising {}." ,
1008
986
statefulIndexMaxHeapSize ,
1009
- PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE .getKey (),
1010
- PRECOMPUTED_PRIVILEGES_INCLUDE_INDICES .getKey ()
987
+ PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE .getKey ()
1011
988
);
1012
989
break top ;
1013
990
}
@@ -1125,16 +1102,11 @@ static String backingIndexToDataStream(String index, Map<String, IndexAbstractio
1125
1102
* <li>Indices which are not matched by includeIndices
1126
1103
* </ul>
1127
1104
*/
1128
- static Map <String , IndexAbstraction > relevantOnly (Map <String , IndexAbstraction > indices , WildcardMatcher includeIndices ) {
1105
+ static Map <String , IndexAbstraction > relevantOnly (Map <String , IndexAbstraction > indices ) {
1129
1106
// First pass: Check if we need to filter at all
1130
1107
boolean doFilter = false ;
1131
1108
1132
1109
for (IndexAbstraction indexAbstraction : indices .values ()) {
1133
- if (includeIndices != null && !includeIndices .test (indexAbstraction .getName ())) {
1134
- doFilter = true ;
1135
- break ;
1136
- }
1137
-
1138
1110
if (indexAbstraction instanceof IndexAbstraction .Index ) {
1139
1111
if (indexAbstraction .getParentDataStream () != null
1140
1112
|| indexAbstraction .getWriteIndex ().getState () == IndexMetadata .State .CLOSE ) {
@@ -1152,10 +1124,6 @@ static Map<String, IndexAbstraction> relevantOnly(Map<String, IndexAbstraction>
1152
1124
ImmutableMap .Builder <String , IndexAbstraction > builder = ImmutableMap .builder ();
1153
1125
1154
1126
for (IndexAbstraction indexAbstraction : indices .values ()) {
1155
- if (includeIndices != null && !includeIndices .test (indexAbstraction .getName ())) {
1156
- continue ;
1157
- }
1158
-
1159
1127
if (indexAbstraction instanceof IndexAbstraction .Index ) {
1160
1128
if (indexAbstraction .getParentDataStream () == null
1161
1129
&& indexAbstraction .getWriteIndex ().getState () != IndexMetadata .State .CLOSE ) {
0 commit comments