Cleanup construction of interceptors
It would be beneficial to apply some of the request interceptors even
when features are disabled. This change reworks the way we build that
list so that the interceptors we always want to use are constructed
outside of the settings check.
Backport of:
@@ -513,17 +513,17 @@ public class Security extends Plugin implements ActionPlugin, IngestPlugin, Netw
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(),
authzService, getLicenseState(), getSslService(), securityContext.get(), destructiveOperations, clusterService));
- final Set<RequestInterceptor> requestInterceptors;
+ Set<RequestInterceptor> requestInterceptors = Sets.newHashSet(
+ new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
+ new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService));
if (XPackSettings.DLS_FLS_ENABLED.get(settings)) {
- requestInterceptors = Collections.unmodifiableSet(Sets.newHashSet(
+ requestInterceptors.addAll(Arrays.asList(
new SearchRequestInterceptor(threadPool, getLicenseState()),
new UpdateRequestInterceptor(threadPool, getLicenseState()),
- new BulkShardRequestInterceptor(threadPool, getLicenseState()),
- new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
- new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService)));
- } else {
- requestInterceptors = Collections.emptySet();
+ new BulkShardRequestInterceptor(threadPool, getLicenseState())
+ ));
}
+ requestInterceptors = Collections.unmodifiableSet(requestInterceptors);
securityActionFilter.set(new SecurityActionFilter(authcService.get(), authzService, getLicenseState(),
requestInterceptors, threadPool, securityContext.get(), destructiveOperations));
