Skip to content

Commit feab43d

Browse files
committed
fix missing token for OpenShiftAPIService requests
1 parent 253f76e commit feab43d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/io/fabric8/elasticsearch/plugin/OpenshiftAPIService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public String userName(final String token) {
6565
try (DefaultOpenShiftClient client = factory.buildClient(token)) {
6666
Request okRequest = new Request.Builder()
6767
.url(client.getMasterUrl() + "apis/user.openshift.io/v1/users/~")
68+
.header("Authorization", "Bearer " + token)
6869
.header(ACCEPT, APPLICATION_JSON)
6970
.build();
7071
response = client.getHttpClient().newCall(okRequest).execute();
@@ -86,6 +87,7 @@ public Set<Project> projectNames(final String token){
8687
try (DefaultOpenShiftClient client = factory.buildClient(token)) {
8788
Request request = new Request.Builder()
8889
.url(client.getMasterUrl() + "apis/project.openshift.io/v1/projects")
90+
.header("Authorization", "Bearer " + token)
8991
.header(ACCEPT, APPLICATION_JSON)
9092
.build();
9193
Response response = client.getHttpClient().newCall(request).execute();
@@ -142,6 +144,7 @@ public boolean localSubjectAccessReview(final String token,
142144
payload.endObject();
143145
Request request = new Request.Builder()
144146
.url(String.format("%sapis/authorization.openshift.io/v1/subjectaccessreviews", client.getMasterUrl(), project))
147+
.header("Authorization", "Bearer " + token)
145148
.header(CONTENT_TYPE, APPLICATION_JSON)
146149
.header(ACCEPT, APPLICATION_JSON)
147150
.post(RequestBody.create(MediaType.parse(APPLICATION_JSON), payload.string()))

src/main/java/io/fabric8/elasticsearch/plugin/OpenshiftRequestContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public OpenshiftRequestContext create(final RestRequest request) throws Exceptio
141141
if (StringUtils.isNotBlank(token)){
142142
try {
143143
return contextCache.get(token);
144-
} catch(ExecutionException e) {
144+
} catch(Exception e) {
145145
LOGGER.error("Error trying to fetch user's context from the cache",e);
146146
}
147147
}

0 commit comments

Comments
 (0)