-
Notifications
You must be signed in to change notification settings - Fork 64
Use auth tokens passed from core and introduce extension and user REST clients #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
12a74d2
5c9dfc8
ab837b6
3f2ee2a
27f0100
0343120
fd519eb
19fff3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
| package org.opensearch.sdk.handlers; | ||
|
|
||
| import joptsimple.internal.Strings; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.opensearch.core.common.bytes.BytesReference; | ||
|
|
@@ -22,6 +23,10 @@ | |
| import org.opensearch.sdk.rest.SDKHttpRequest; | ||
| import org.opensearch.sdk.rest.SDKRestRequest; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||
| import static java.util.Collections.emptyMap; | ||
| import static java.util.Collections.emptyList; | ||
|
|
@@ -68,11 +73,19 @@ public RestExecuteOnExtensionResponse handleRestExecuteOnExtensionRequest(Extens | |
| ); | ||
| } | ||
|
|
||
| String oboToken = request.getRequestIssuerIdentity(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this should be called an onBehalfOfToken both here and on the request object? What do you think about making the type
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I think this needs to be updated in core. I can create a PR for that. |
||
| Map<String, List<String>> headers = new HashMap<>(); | ||
| headers.putAll(request.headers()); | ||
| System.out.println("oboToken: " + oboToken); | ||
| if (!Strings.isNullOrEmpty(oboToken)) { | ||
| headers.put("Authorization", List.of("Bearer " + oboToken)); | ||
| } | ||
|
|
||
| SDKRestRequest sdkRestRequest = new SDKRestRequest( | ||
| sdkNamedXContentRegistry.getRegistry(), | ||
| request.params(), | ||
| request.path(), | ||
| request.headers(), | ||
| headers, | ||
| new SDKHttpRequest(request), | ||
| null | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.