|
80 | 80 | import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
|
81 | 81 | import org.opensearch.cluster.metadata.Metadata;
|
82 | 82 | import org.opensearch.cluster.service.ClusterService;
|
| 83 | +import org.opensearch.common.settings.ClusterSettings; |
83 | 84 | import org.opensearch.common.settings.Settings;
|
84 | 85 | import org.opensearch.common.util.concurrent.ThreadContext;
|
85 | 86 | import org.opensearch.core.common.Strings;
|
|
105 | 106 | import org.opensearch.security.securityconf.impl.v7.TenantV7;
|
106 | 107 | import org.opensearch.security.support.Base64Helper;
|
107 | 108 | import org.opensearch.security.support.ConfigConstants;
|
| 109 | +import org.opensearch.security.support.SecuritySettings; |
108 | 110 | import org.opensearch.security.support.WildcardMatcher;
|
109 | 111 | import org.opensearch.security.user.User;
|
110 | 112 | import org.opensearch.tasks.Task;
|
@@ -153,6 +155,7 @@ public class PrivilegesEvaluator {
|
153 | 155 | private PrivilegesInterceptor privilegesInterceptor;
|
154 | 156 |
|
155 | 157 | private final boolean checkSnapshotRestoreWritePrivileges;
|
| 158 | + private boolean isUserAttributeSerializationEnabled; |
156 | 159 |
|
157 | 160 | private final ClusterInfoHolder clusterInfoHolder;
|
158 | 161 | private final ConfigurationRepository configurationRepository;
|
@@ -204,6 +207,10 @@ public PrivilegesEvaluator(
|
204 | 207 | ConfigConstants.SECURITY_CHECK_SNAPSHOT_RESTORE_WRITE_PRIVILEGES,
|
205 | 208 | ConfigConstants.SECURITY_DEFAULT_CHECK_SNAPSHOT_RESTORE_WRITE_PRIVILEGES
|
206 | 209 | );
|
| 210 | + this.isUserAttributeSerializationEnabled = settings.getAsBoolean( |
| 211 | + USER_ATTRIBUTE_SERIALIZATION_ENABLED, |
| 212 | + USER_ATTRIBUTE_SERIALIZATION_ENABLED_DEFAULT |
| 213 | + ); |
207 | 214 |
|
208 | 215 | this.clusterInfoHolder = clusterInfoHolder;
|
209 | 216 | this.irr = irr;
|
@@ -236,6 +243,8 @@ public PrivilegesEvaluator(
|
236 | 243 | actionPrivileges.clusterStateMetadataDependentPrivileges().updateClusterStateMetadataAsync(clusterService, threadPool);
|
237 | 244 | }
|
238 | 245 | });
|
| 246 | + |
| 247 | + this.registerClusterSettingsChangeListener(clusterService.getClusterSettings()); |
239 | 248 | }
|
240 | 249 | }
|
241 | 250 |
|
@@ -286,8 +295,17 @@ public boolean isInitialized() {
|
286 | 295 | return configModel != null && dcm != null && actionPrivileges.get() != null;
|
287 | 296 | }
|
288 | 297 |
|
| 298 | + public void registerClusterSettingsChangeListener(final ClusterSettings clusterSettings) { |
| 299 | + clusterSettings.addSettingsUpdateConsumer( |
| 300 | + SecuritySettings.USER_ATTRIBUTE_SERIALIZATION_ENABLED_SETTING, |
| 301 | + newIsUserAttributeSerializationEnabled -> { |
| 302 | + isUserAttributeSerializationEnabled = newIsUserAttributeSerializationEnabled; |
| 303 | + } |
| 304 | + ); |
| 305 | + } |
| 306 | + |
289 | 307 | private boolean isUserAttributeSerializationEnabled() {
|
290 |
| - return this.settings.getAsBoolean(USER_ATTRIBUTE_SERIALIZATION_ENABLED, USER_ATTRIBUTE_SERIALIZATION_ENABLED_DEFAULT); |
| 308 | + return isUserAttributeSerializationEnabled; |
291 | 309 | }
|
292 | 310 |
|
293 | 311 | private void setUserInfoInThreadContext(PrivilegesEvaluationContext context) {
|
|
0 commit comments