diff --git a/src/oidc.js b/src/oidc.js index 6e3477c1b..77933301e 100644 --- a/src/oidc.js +++ b/src/oidc.js @@ -11,7 +11,6 @@ exports = module.exports = { }, routes: { renderInteractionPage, - renderSessionEndPage, interactionLogin, interactionConfirm, interactionAbort @@ -163,7 +162,7 @@ class CloudronAdapter { client_id: id, client_secret: client.secret, redirect_uris: [ client.loginRedirectUri ], - post_logout_redirect_uri: client.logoutRedirectUri, + post_logout_redirect_uris: [ client.logoutRedirectUri ], }; } else { if (!this.store[id]) return false; @@ -284,17 +283,6 @@ class CloudronAdapter { } } -function renderSessionEndPage(routePrefix, provider) { - assert.strictEqual(typeof routePrefix, 'string'); - assert.strictEqual(typeof provider, 'object'); - - return async function (req, res, next) { - debug(`route session end get`); - - return res.render('session_end', {}); - }; -} - function renderInteractionPage(routePrefix, provider) { assert.strictEqual(typeof routePrefix, 'string'); assert.strictEqual(typeof provider, 'object'); @@ -504,6 +492,46 @@ async function claims(userId, use, scope) { return claims; } +async function logoutSource(ctx, form) { + // @param ctx - koa request context + // @param form - form source (id="op.logoutForm") to be embedded in the page and submitted by + // the End-User + ctx.body = ` + + Logout Request + + + +
+

Cloudron Do you want to sign-out from ${ctx.host}?

+ ${form} + + +
+ + `; +} + +async function postLogoutSuccessSource(ctx) { + // @param ctx - koa request context + const { + clientId, clientName, clientUri, initiateLoginUri, logoUri, policyUri, tosUri, + } = ctx.oidc.client || {}; // client is defined if the user chose to stay logged in with the OP + const display = clientName || clientId; + ctx.body = ` + + Sign-out Success + + + +
+

Cloudron Sign-out Success

+

Your sign-out ${display ? `with ${display}` : ''} was successful.

+
+ + `; +} + async function getProvider(routePrefix) { assert.strictEqual(typeof routePrefix, 'string'); @@ -529,7 +557,12 @@ async function getProvider(routePrefix) { profile: [ 'family_name', 'given_name', 'locale', 'name', 'preferred_username' ] }, features: { - devInteractions: { enabled: false } + devInteractions: { enabled: false }, + rpInitiatedLogout: { + enabled: true, + logoutSource, + postLogoutSuccessSource + }, }, // if a client only has one redirect uri specified, the client does not have to provide it in the request allowOmittingSingleRegisteredRedirectUri: true, diff --git a/src/oidc_templates/session_end.ejs b/src/oidc_templates/session_end.ejs deleted file mode 100644 index a849640ba..000000000 --- a/src/oidc_templates/session_end.ejs +++ /dev/null @@ -1,23 +0,0 @@ - - - - - Logout Request - - - - - -
-

Do you want to sign-out?

-
- -
- - -
- - - \ No newline at end of file diff --git a/src/server.js b/src/server.js index 5b0ca4db8..fd6abe240 100644 --- a/src/server.js +++ b/src/server.js @@ -385,7 +385,6 @@ async function initializeExpressSync() { router.post('/api/v1/oidc/interaction/:uid/login', setNoCache, json, oidc.routes.interactionLogin(oidcProvider)); router.post('/api/v1/oidc/interaction/:uid/confirm', setNoCache, json, oidc.routes.interactionConfirm(oidcProvider)); router.get ('/api/v1/oidc/interaction/:uid/abort', setNoCache, oidc.routes.interactionAbort(oidcProvider)); - router.get ('/api/v1/oidc/session/end', setNoCache, oidc.routes.renderSessionEndPage(oidcPrefix, oidcProvider)); app.use(oidcPrefix, oidcProvider.callback());