Skip to content
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

fix: send bearer auth correctly #192

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ The original work is also licensed under the Apache 2 License.
Here's a command-line guide to uploading some payload:

```
export BASIC_AUTH='the-token'
export AUTH='the-token'
export HOST='the-host'

curl -F "file=@foo.json.gz;type=application/vnd.redhat.runtimes-java-general.analytics+tgz" \
-H "Authorization: Basic ${BASIC_AUTH}" \
-H "Authorization: Bearer ${AUTH}" \
"https://${HOST}/api/ingress/v1/upload" -v --insecure
```

Expand All @@ -62,7 +62,7 @@ Or if you prefer HTTPie:
http --verbose --multipart $HOST/api/ingress/v1/upload \
'file@foo.json.gz;type=application/vnd.redhat.runtimes-java-general.analytics+tgz' \
type='application/vnd.redhat.runtimes-java-general.analytics+tgz' \
"Authorization":"Basic ${BASIC_AUTH}"
"Authorization":"Bearer ${AUTH}"
```

## Environment variables and system properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.core.httpclient;

import static com.redhat.insights.InsightsErrorCode.*;
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void sendInsightsReportWithClient(

if (!configuration.useMTLS()) {
final var authToken = configuration.getMaybeAuthToken().get();
requestBuilder = requestBuilder.setHeader("Authorization", "Basic " + authToken);
requestBuilder = requestBuilder.setHeader("Authorization", "Bearer " + authToken);
}
requestBuilder =
requestBuilder.uri(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.core.httpclient;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testSendReportWithoutMtls() throws IOException, InterruptedException

// if using token, there should be authorization header
assertEquals(1, request.get().headers().allValues("Authorization").size());
assertEquals("Basic randomToken", request.get().headers().allValues("Authorization").get(0));
assertEquals("Bearer randomToken", request.get().headers().allValues("Authorization").get(0));
}

@Test
Expand Down