diff --git a/CHANGELOG.md b/CHANGELOG.md index c247334bc0f26..389a4e5493ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Make Engine#loadHistoryUUID() protected and Origin#isFromTranslog() public ([#19753](https://github.com/opensearch-project/OpenSearch/pull/19752)) - Bump opensearch-protobufs dependency to 0.23.0 and update transport-grpc module compatibility ([#19831](https://github.com/opensearch-project/OpenSearch/pull/19831)) - Refactor the DocStats and StoreStats class to use the Builder pattern instead of constructors ([#19863](https://github.com/opensearch-project/OpenSearch/pull/19863)) +- Pass registry of headers from ActionPlugin.getRestHeaders to ActionPlugin.getRestHandlerWrapper ([#19875](https://github.com/opensearch-project/OpenSearch/pull/19875)) ### Fixed - Fix Allocation and Rebalance Constraints of WeightFunction are incorrectly reset ([#19012](https://github.com/opensearch-project/OpenSearch/pull/19012)) diff --git a/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java b/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java index 4ca61ddeb6bcd..33dd00f37f31a 100644 --- a/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java +++ b/plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java @@ -32,6 +32,7 @@ import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestHandler; +import org.opensearch.rest.RestHeaderDefinition; import org.opensearch.rest.RestRequest; import org.opensearch.script.ScriptService; import org.opensearch.threadpool.ThreadPool; @@ -41,6 +42,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Set; import java.util.function.Supplier; import java.util.function.UnaryOperator; @@ -107,7 +109,7 @@ public TokenManager getTokenManager() { } @Override - public UnaryOperator getRestHandlerWrapper(ThreadContext threadContext) { + public UnaryOperator getRestHandlerWrapper(ThreadContext threadContext, Set headersToCopy) { return AuthcRestHandler::new; } diff --git a/server/src/main/java/org/opensearch/action/ActionModule.java b/server/src/main/java/org/opensearch/action/ActionModule.java index c4a78c288c26e..0df5e07d5b027 100644 --- a/server/src/main/java/org/opensearch/action/ActionModule.java +++ b/server/src/main/java/org/opensearch/action/ActionModule.java @@ -595,7 +595,7 @@ public ActionModule( ).collect(Collectors.toSet()); UnaryOperator restWrapper = null; for (ActionPlugin plugin : actionPlugins) { - UnaryOperator newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext()); + UnaryOperator newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext(), headers); if (newRestWrapper != null) { logger.debug("Using REST wrapper from plugin " + plugin.getClass().getName()); if (restWrapper != null) { diff --git a/server/src/main/java/org/opensearch/plugins/ActionPlugin.java b/server/src/main/java/org/opensearch/plugins/ActionPlugin.java index fadf17ef48622..6bcb5ccd3a691 100644 --- a/server/src/main/java/org/opensearch/plugins/ActionPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/ActionPlugin.java @@ -57,6 +57,7 @@ import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.function.Supplier; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -148,7 +149,7 @@ default Collection getTaskHeaders() { * * Note: Only one installed plugin may implement a rest wrapper. */ - default UnaryOperator getRestHandlerWrapper(ThreadContext threadContext) { + default UnaryOperator getRestHandlerWrapper(ThreadContext threadContext, Set headersToCopy) { return null; }