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 statuscode of backchannel logout response #1692

Closed
Closed
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 docs/classes/http_auth0_next_response.default.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/auth0-session/handlers/backchannel-logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function backchannelLogoutHandlerFactory(
} catch (e) {
throw new BackchannelLogoutError('application_error', e.message);
}
res.send204();
res.sendEmpty200();
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/auth0-session/http/auth0-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default abstract class Auth0Response<Res = any> extends Auth0ResponseCook

public abstract redirect(location: string, status?: number): void;

public abstract send204(): void;
public abstract sendEmpty200(): void;

public abstract setHeader(name: string, value: string): void;
}
4 changes: 2 additions & 2 deletions src/auth0-session/http/node-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default class NodeResponse<T extends ServerResponse = ServerResponse> ext
this.res.end(htmlSafe(location));
}

public send204(): void {
this.res.statusCode = 204;
public sendEmpty200(): void {
this.res.statusCode = 200;
this.res.end();
}

Expand Down
4 changes: 2 additions & 2 deletions src/http/auth0-next-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export default class Auth0NextResponse extends Auth0Response<NextResponse> {
this.res.headers.set(name, value);
}

public send204() {
public sendEmpty200() {
const oldRes = this.res;
this.res = new NextResponse(null, { status: 204 });
this.res = new NextResponse(null, { status: 200 });
oldRes.headers.forEach((value, key) => {
this.res.headers.set(key, value);
});
Expand Down
8 changes: 4 additions & 4 deletions tests/auth0-session/handlers/backchannel-logout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('backchannel-logout', () => {
},
data: {}
});
expect(res.statusCode).toEqual(204);
expect(res.statusCode).toEqual(200);
await expect(isLoggedOut({ sid: 'foo' }, getConfig({ baseURL, ...params }))).resolves.toEqual(true);
});

Expand All @@ -46,7 +46,7 @@ describe('backchannel-logout', () => {
await expect(store.get('sub|__test_client_id__|bar')).resolves.toMatchObject({
data: {}
});
expect(res.statusCode).toEqual(204);
expect(res.statusCode).toEqual(200);
await expect(isLoggedOut({ sid: 'foo' }, getConfig({ baseURL, ...params }))).resolves.toEqual(true);
await expect(isLoggedOut({ sub: 'bar' }, getConfig({ baseURL, ...params }))).resolves.toEqual(true);
await expect(isLoggedOut({ sid: 'foo', sub: 'bar' }, getConfig({ baseURL, ...params }))).resolves.toEqual(true);
Expand All @@ -64,7 +64,7 @@ describe('backchannel-logout', () => {
await expect(store.get('sub|__test_client_id__|bar')).resolves.toMatchObject({
data: {}
});
expect(res.statusCode).toEqual(204);
expect(res.statusCode).toEqual(200);
await expect(isLoggedOut({ sub: 'bar' }, getConfig({ baseURL, ...params }))).resolves.toEqual(true);
});

Expand Down Expand Up @@ -97,7 +97,7 @@ describe('backchannel-logout', () => {
},
data: {}
});
expect(res.statusCode).toEqual(204);
expect(res.statusCode).toEqual(200);
});

it('should delete a sub entry from the logout store', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/backchannel-logout-page-router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('backchannel-logout handler (page router)', () => {

await expect(
post(baseUrl, '/api/auth/backchannel-logout', { fullResponse: true, body: `logout_token=${logoutToken}` })
).resolves.toMatchObject({ res: { statusCode: 204 } });
).resolves.toMatchObject({ res: { statusCode: 200 } });
});

test('should save tokens into the store when a valid logout token is provided', async () => {
Expand All @@ -57,7 +57,7 @@ describe('backchannel-logout handler (page router)', () => {
fullResponse: true,
body: `logout_token=${logoutToken}`
});
expect(res.statusCode).toBe(204);
expect(res.statusCode).toBe(200);
expect(res.headers['cache-control']).toBe('no-store');
await expect(store.get('sid|__test_client_id__|foo')).resolves.toMatchObject({ data: {} });
await expect(store.get('sub|__test_client_id__|bar')).resolves.toMatchObject({ data: {} });
Expand Down
4 changes: 2 additions & 2 deletions tests/handlers/backchannel-logout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('backchannel-logout handler (app router)', () => {
url: '/api/auth/backchannel-logout',
reqInit: { method: 'post', body: `logout_token=${logoutToken}` }
});
expect(res.status).toBe(204);
expect(res.status).toBe(200);
expect(res.headers.get('cache-control')).toBe('no-store');
});

Expand All @@ -86,7 +86,7 @@ describe('backchannel-logout handler (app router)', () => {
url: '/api/auth/backchannel-logout',
reqInit: { method: 'post', body: `logout_token=${logoutToken}` }
})
).resolves.toMatchObject({ status: 204 });
).resolves.toMatchObject({ status: 200 });
await expect(store.get('sid|__test_client_id__|foo')).resolves.toMatchObject({ data: {} });
await expect(store.get('sub|__test_client_id__|bar')).resolves.toMatchObject({ data: {} });
});
Expand Down
Loading