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

Get the ID Token before deleting the session #267

Merged
merged 1 commit into from
Feb 1, 2021
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
3 changes: 2 additions & 1 deletion src/auth0-session/handlers/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function logoutHandlerFactory(
return;
}

const idToken = sessionCache.getIdToken(req, res);
sessionCache.delete(req, res);

if (!config.idpLogout) {
Expand All @@ -46,7 +47,7 @@ export default function logoutHandlerFactory(
const client = await getClient();
returnURL = client.endSessionUrl({
post_logout_redirect_uri: returnURL,
id_token_hint: sessionCache.getIdToken(req, res)
id_token_hint: idToken
});

debug('logging out of identity provider, redirecting to %s', returnURL);
Expand Down
7 changes: 5 additions & 2 deletions tests/auth0-session/handlers/logout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('logout route', () => {
});

it('should perform a distributed logout', async () => {
const baseURL = await setup({ ...defaultConfig, idpLogout: true });
const baseURL = await setup({ ...defaultConfig, auth0Logout: false, idpLogout: true });
const cookieJar = await login(baseURL);

const session: SessionResponse = await get(baseURL, '/session', { cookieJar });
Expand All @@ -71,7 +71,10 @@ describe('logout route', () => {
hostname: 'op.example.com',
pathname: '/session/end',
protocol: 'https:',
query: expect.objectContaining({ post_logout_redirect_uri: baseURL })
query: {
post_logout_redirect_uri: baseURL,
id_token_hint: session.id_token
}
});
});

Expand Down