Skip to content

Commit db72ca2

Browse files
authored
Pass registry of headers from ActionPlugin.getRestHeaders to ActionPlugin.getRestHandlerWrapper (opensearch-project#19875)
* Pass registry of headers from ActionPlugin.getRestHeaders to ActionPlugin.getRestHandlerWrapper Signed-off-by: Craig Perkins <cwperx@amazon.com> * Add to CHANGELOG Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent 4d04fc0 commit db72ca2

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3535
- Make Engine#loadHistoryUUID() protected and Origin#isFromTranslog() public ([#19753](https://github.com/opensearch-project/OpenSearch/pull/19752))
3636
- Bump opensearch-protobufs dependency to 0.23.0 and update transport-grpc module compatibility ([#19831](https://github.com/opensearch-project/OpenSearch/pull/19831))
3737
- Refactor the DocStats and StoreStats class to use the Builder pattern instead of constructors ([#19863](https://github.com/opensearch-project/OpenSearch/pull/19863))
38+
- Pass registry of headers from ActionPlugin.getRestHeaders to ActionPlugin.getRestHandlerWrapper ([#19875](https://github.com/opensearch-project/OpenSearch/pull/19875))
3839

3940
### Fixed
4041
- Fix Allocation and Rebalance Constraints of WeightFunction are incorrectly reset ([#19012](https://github.com/opensearch-project/OpenSearch/pull/19012))

plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.opensearch.rest.BytesRestResponse;
3333
import org.opensearch.rest.RestChannel;
3434
import org.opensearch.rest.RestHandler;
35+
import org.opensearch.rest.RestHeaderDefinition;
3536
import org.opensearch.rest.RestRequest;
3637
import org.opensearch.script.ScriptService;
3738
import org.opensearch.threadpool.ThreadPool;
@@ -41,6 +42,7 @@
4142

4243
import java.util.Collection;
4344
import java.util.Collections;
45+
import java.util.Set;
4446
import java.util.function.Supplier;
4547
import java.util.function.UnaryOperator;
4648

@@ -107,7 +109,7 @@ public TokenManager getTokenManager() {
107109
}
108110

109111
@Override
110-
public UnaryOperator<RestHandler> getRestHandlerWrapper(ThreadContext threadContext) {
112+
public UnaryOperator<RestHandler> getRestHandlerWrapper(ThreadContext threadContext, Set<RestHeaderDefinition> headersToCopy) {
111113
return AuthcRestHandler::new;
112114
}
113115

server/src/main/java/org/opensearch/action/ActionModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public ActionModule(
595595
).collect(Collectors.toSet());
596596
UnaryOperator<RestHandler> restWrapper = null;
597597
for (ActionPlugin plugin : actionPlugins) {
598-
UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext());
598+
UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext(), headers);
599599
if (newRestWrapper != null) {
600600
logger.debug("Using REST wrapper from plugin " + plugin.getClass().getName());
601601
if (restWrapper != null) {

server/src/main/java/org/opensearch/plugins/ActionPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import java.util.Collections;
5858
import java.util.List;
5959
import java.util.Objects;
60+
import java.util.Set;
6061
import java.util.function.Supplier;
6162
import java.util.function.UnaryOperator;
6263
import java.util.stream.Collectors;
@@ -148,7 +149,7 @@ default Collection<String> getTaskHeaders() {
148149
*
149150
* Note: Only one installed plugin may implement a rest wrapper.
150151
*/
151-
default UnaryOperator<RestHandler> getRestHandlerWrapper(ThreadContext threadContext) {
152+
default UnaryOperator<RestHandler> getRestHandlerWrapper(ThreadContext threadContext, Set<RestHeaderDefinition> headersToCopy) {
152153
return null;
153154
}
154155

0 commit comments

Comments
 (0)