Skip to content

Commit

Permalink
Change CLX-Authorization header to Authorization #178
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Jun 19, 2024
1 parent 70c8ee9 commit 0104958
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/app/shared/interceptors/rest-auth.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("restAuthInterceptor", () => {
describe("authenticated", () => {
beforeEach(() => (accessToken = "abcdefghijklmnopqrstuvwxyz"));

it("adds CLX-Authorization header to request for API requests", () => {
it("adds Authorization header to request for API requests", () => {
intercept("https://eventotest.api/foo").subscribe({
next: successCallback,
error: errorCallback,
Expand All @@ -64,12 +64,12 @@ describe("restAuthInterceptor", () => {
expect(nextCallback).toHaveBeenCalled();

const req = nextCallback.calls.mostRecent().args[0];
expect(req.headers.get("CLX-Authorization")).toBe(
"token_type=urn:ietf:params:oauth:token-type:jwt-bearer, access_token=abcdefghijklmnopqrstuvwxyz",
expect(req.headers.get("Authorization")).toBe(
"Bearer abcdefghijklmnopqrstuvwxyz",
);
});

it("does not add CLX-Authorization header to request for non-API requests", () => {
it("does not add Authorization header to request for non-API requests", () => {
intercept("http://example.com").subscribe({
next: successCallback,
error: errorCallback,
Expand All @@ -80,14 +80,14 @@ describe("restAuthInterceptor", () => {
expect(nextCallback).toHaveBeenCalled();

const req = nextCallback.calls.mostRecent().args[0];
expect(req.headers.has("CLX-Authorization")).toBeFalsy();
expect(req.headers.has("Authorization")).toBeFalsy();
});
});

describe("unauthenticated", () => {
beforeEach(() => (accessToken = null));

it("does not add CLX-Authorization header to request", () => {
it("does not add Authorization header to request", () => {
intercept("https://eventotest.api/foo").subscribe({
next: successCallback,
error: errorCallback,
Expand All @@ -98,7 +98,7 @@ describe("restAuthInterceptor", () => {
expect(nextCallback).toHaveBeenCalled();

const req = nextCallback.calls.mostRecent().args[0];
expect(req.headers.has("CLX-Authorization")).toBeFalsy();
expect(req.headers.has("Authorization")).toBeFalsy();
});
});
});
6 changes: 3 additions & 3 deletions src/app/shared/interceptors/rest-auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SETTINGS, Settings } from "src/app/settings";
import { AuthService } from "src/app/shared/services/auth.service";

/**
* Adds the CLX-Authorization HTTP header to API requests.
* Adds the Authorization HTTP header to API requests.
*/
export function restAuthInterceptor(): HttpInterceptorFn {
return (req, next) => {
Expand All @@ -13,8 +13,8 @@ export function restAuthInterceptor(): HttpInterceptorFn {

if (req.url.startsWith(settings.apiUrl) && auth.accessToken) {
const headers = req.headers.set(
"CLX-Authorization",
`token_type=urn:ietf:params:oauth:token-type:jwt-bearer, access_token=${auth.accessToken}`,
"Authorization",
`Bearer ${auth.accessToken}`,
);
return next(req.clone({ headers }));
}
Expand Down

0 comments on commit 0104958

Please sign in to comment.