Skip to content

Commit

Permalink
Only set X-Opaque-Id if present
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Oct 6, 2023
1 parent 782d27f commit 4abc12e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ public RestHandler wrap(RestHandler original, AdminDNs adminDNs) {
// X_OPAQUE_ID will be overritten on restore - save to apply after restoring the saved context
final String xOpaqueId = threadContext.getHeader(Task.X_OPAQUE_ID);
storedContext.restore();
threadContext.putHeader(Task.X_OPAQUE_ID, xOpaqueId);
if (xOpaqueId != null) {
threadContext.putHeader(Task.X_OPAQUE_ID, xOpaqueId);
}
});

final SecurityRequestChannel requestChannel = SecurityRequestFactory.from(request, channel);

// Authenticate request
if(!NettyAttribute.popFrom(request, IS_AUTHENTICATED).orElse(false)) {
if (!NettyAttribute.popFrom(request, IS_AUTHENTICATED).orElse(false)) {
// we aren't authenticated so we should skip this step
checkAndAuthenticateRequest(requestChannel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public void channelRead0(ChannelHandlerContext ctx, DefaultHttpRequest msg) thro

// TODO: GET PROPER MAVEN BUILD
// final Netty4HttpChannel httpChannel = ctx.channel().attr(Netty4HttpServerTransport.HTTP_CHANNEL_KEY).get();
final Netty4HttpChannel httpChannel = ctx.channel()
.attr(AttributeKey.<Netty4HttpChannel>valueOf("opensearch-http-channel"))
.get();
final Netty4HttpChannel httpChannel = ctx.channel().attr(AttributeKey.<Netty4HttpChannel>valueOf("opensearch-http-channel")).get();
Matcher matcher = PATTERN_PATH_PREFIX.matcher(msg.uri());
final String suffix = matcher.matches() ? matcher.group(2) : null;
if (API_AUTHTOKEN_SUFFIX.equals(suffix)) {
Expand Down

0 comments on commit 4abc12e

Please sign in to comment.