Skip to content

Commit 2937151

Browse files
authored
Cleanup construction of interceptors (#38388)
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: #38294
1 parent d0aaf14 commit 2937151

File tree

1 file changed

+9
-9
lines changed
  • x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security

1 file changed

+9
-9
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -509,17 +509,17 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
509509
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(),
510510
authzService, getLicenseState(), getSslService(), securityContext.get(), destructiveOperations, clusterService));
511511

512-
final Set<RequestInterceptor> requestInterceptors;
512+
Set<RequestInterceptor> requestInterceptors = Sets.newHashSet(
513+
new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
514+
new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService));
513515
if (XPackSettings.DLS_FLS_ENABLED.get(settings)) {
514-
requestInterceptors = Collections.unmodifiableSet(Sets.newHashSet(
515-
new SearchRequestInterceptor(threadPool, getLicenseState()),
516-
new UpdateRequestInterceptor(threadPool, getLicenseState()),
517-
new BulkShardRequestInterceptor(threadPool, getLicenseState()),
518-
new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
519-
new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService)));
520-
} else {
521-
requestInterceptors = Collections.emptySet();
516+
requestInterceptors.addAll(Arrays.asList(
517+
new SearchRequestInterceptor(threadPool, getLicenseState()),
518+
new UpdateRequestInterceptor(threadPool, getLicenseState()),
519+
new BulkShardRequestInterceptor(threadPool, getLicenseState())
520+
));
522521
}
522+
requestInterceptors = Collections.unmodifiableSet(requestInterceptors);
523523

524524
securityActionFilter.set(new SecurityActionFilter(authcService.get(), authzService, getLicenseState(),
525525
requestInterceptors, threadPool, securityContext.get(), destructiveOperations));

0 commit comments

Comments
 (0)