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 post logout redirect, add config for default #40

Merged
merged 23 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b66cd83
add new ways to specify post logout redirect url
balazsorban44 Nov 26, 2019
19cb830
destroy session after calling endSessionUrl
balazsorban44 Nov 26, 2019
0c2401d
whitespace formatting
balazsorban44 Nov 26, 2019
6193f07
changes after code review
balazsorban44 Dec 6, 2019
fd5070a
update logout tests to cover new cases
balazsorban44 Dec 6, 2019
4063ab4
add postLogoutRedirectUri to optional keys
balazsorban44 Dec 6, 2019
46eb8a9
add postLogoutRedirectParams to ConfigParams
balazsorban44 Dec 6, 2019
7162c46
Merge branch 'master' into 'post-logout-redirect'
balazsorban44 Jan 13, 2020
a874d33
make postLogoutRedirectUri relative
balazsorban44 Jan 13, 2020
0ca9e8e
add tests for postRedirectUrl and returnTo query string
balazsorban44 Jan 13, 2020
c907f75
Merge branch 'master' into post-logout-redirect
balazsorban44 Jan 14, 2020
1b8b4c2
Merge branch 'master' into post-logout-redirect
balazsorban44 Jan 16, 2020
2886790
accept relative path and full URI in postLogoutRedirectUri
balazsorban44 Jan 16, 2020
6454f80
add postLogoutRedirectUri tests, relative path & full URI
balazsorban44 Jan 16, 2020
0ddc8b4
update description of postLogoutRedirectUri in API.md
balazsorban44 Jan 16, 2020
678d075
add postLogoutRedirectUris to docs and typings
balazsorban44 Jan 16, 2020
3084c01
require returnTo URIs to be present in postLogoutRedirectUris
balazsorban44 Jan 16, 2020
e4b6c07
add tests for postLogoutRedirectUris
balazsorban44 Jan 16, 2020
903a23b
Revert adding postLogoutRedirectUris
balazsorban44 Jan 23, 2020
5e9b7f3
Merge branch 'master' into post-logout-redirect
balazsorban44 Jan 23, 2020
36c13a7
changes after code review
balazsorban44 Jan 23, 2020
2bae74c
fix logout tests
balazsorban44 Jan 23, 2020
586feaa
Merge branch 'master' into post-logout-redirect
balazsorban44 Jan 23, 2020
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"indent": [
"error",
2,
{ "SwitchCase": 1 }
{ "SwitchCase": 1 }
],
"linebreak-style": [
"error",
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const paramsSchema = Joi.object().keys({
errorOnRequiredAuth: Joi.boolean().optional().default(false),
auth0Logout: Joi.boolean().optional().default(false),
redirectUriPath: Joi.string().optional().default('/callback'),
post_logout_redirect_uri: Joi.string().optional(),
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
loginPath: Joi.string().optional().default('/login'),
logoutPath: Joi.string().optional().default('/logout'),
idpLogout: Joi.boolean().optional().default(false)
Expand Down
15 changes: 8 additions & 7 deletions lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,12 @@ class ResponseContext {
const next = cb(this._next).once();
const req = this._req;
const res = this._res;
const returnURL = params.returnTo || this._config.baseURL;
const returnURL = params.returnTo || req.query.returnTo || this._config.post_logout_redirect_uri || this._config.baseURL;
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved

if (!req.session || !req.openid) {
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
return res.redirect(returnURL);
}

if (typeof req.session.destroy === 'function') {
req.session.destroy();
} else {
req.session = null;
}

if (!this._config.idpLogout) {
return res.redirect(returnURL);
}
Expand All @@ -116,6 +110,13 @@ class ResponseContext {
post_logout_redirect_uri: returnURL,
id_token_hint: req.openid.tokens,
});

if (typeof req.session.destroy === 'function') {
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
req.session.destroy();
} else {
req.session = null;
}

res.redirect(url);
} catch(err) {
next(err);
Expand Down