Skip to content

Commit 0164acb

Browse files
authored
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.
1 parent 75f0750 commit 0164acb

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,17 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
449449
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(),
450450
authzService, getLicenseState(), getSslService(), securityContext.get(), destructiveOperations, clusterService));
451451

452-
final Set<RequestInterceptor> requestInterceptors;
452+
Set<RequestInterceptor> requestInterceptors = Sets.newHashSet(
453+
new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
454+
new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService));
453455
if (XPackSettings.DLS_FLS_ENABLED.get(settings)) {
454-
requestInterceptors = Collections.unmodifiableSet(Sets.newHashSet(
455-
new SearchRequestInterceptor(threadPool, getLicenseState()),
456-
new UpdateRequestInterceptor(threadPool, getLicenseState()),
457-
new BulkShardRequestInterceptor(threadPool, getLicenseState()),
458-
new ResizeRequestInterceptor(threadPool, getLicenseState(), auditTrailService),
459-
new IndicesAliasesRequestInterceptor(threadPool.getThreadContext(), getLicenseState(), auditTrailService)));
460-
} else {
461-
requestInterceptors = Collections.emptySet();
456+
requestInterceptors.addAll(Arrays.asList(
457+
new SearchRequestInterceptor(threadPool, getLicenseState()),
458+
new UpdateRequestInterceptor(threadPool, getLicenseState()),
459+
new BulkShardRequestInterceptor(threadPool, getLicenseState())
460+
));
462461
}
462+
requestInterceptors = Collections.unmodifiableSet(requestInterceptors);
463463

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

0 commit comments

Comments
 (0)