Cleanup construction of interceptors (#38294)

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.
This commit is contained in:
Tim Vernum 2019-02-04 17:27:41 +11:00 committed by GitHub
parent 75f0750ff7
commit 0164acb0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -449,17 +449,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(
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();
requestInterceptors.addAll(Arrays.asList(
new SearchRequestInterceptor(threadPool, getLicenseState()),
new UpdateRequestInterceptor(threadPool, getLicenseState()),
new BulkShardRequestInterceptor(threadPool, getLicenseState())
));
}
requestInterceptors = Collections.unmodifiableSet(requestInterceptors);
securityActionFilter.set(new SecurityActionFilter(authcService.get(), authzService, getLicenseState(),
requestInterceptors, threadPool, securityContext.get(), destructiveOperations));