From 6b66f143198f2de9e5d1403ad4a0ef9ff08131d3 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 25 Nov 2020 15:57:11 -0600 Subject: [PATCH] Update web sso content to indicate window OK to close (#720) * Update web sso content to indicate window OK to close This is done after the authResult handoff message is delivered to the extension. It is not possible to close the window from javascript as closing a window is limited to the script that opened it. If we maintain a reference to the web window, it should be possible to subscribe to the authResult message and close the web windows from the browser. * Use i18n for close tab message * delete cookie after it is used Co-authored-by: Matt Gibson --- src/app/accounts/sso.component.ts | 3 +++ src/connectors/sso.html | 8 +++++--- src/connectors/sso.ts | 4 ++++ src/locales/en/messages.json | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/accounts/sso.component.ts b/src/app/accounts/sso.component.ts index 0c80ac5fa1..f71f478aea 100644 --- a/src/app/accounts/sso.component.ts +++ b/src/app/accounts/sso.component.ts @@ -53,6 +53,9 @@ export class SsoComponent extends BaseSsoComponent { async submit() { await this.storageService.save(IdentifierStorageKey, this.identifier); + if (this.clientId === 'browser') { + document.cookie = `ssoHandOffMessage=${this.i18nService.t('ssoHandOff')};SameSite=strict` + } super.submit(); } } diff --git a/src/connectors/sso.html b/src/connectors/sso.html index b82716764e..32078c2954 100644 --- a/src/connectors/sso.html +++ b/src/connectors/sso.html @@ -19,9 +19,11 @@
-

- -

+
+

+ +

+
diff --git a/src/connectors/sso.ts b/src/connectors/sso.ts index a21e5fcd67..46457b7bc4 100644 --- a/src/connectors/sso.ts +++ b/src/connectors/sso.ts @@ -37,6 +37,10 @@ function getQsParam(name: string) { function initiateBrowserSso(code: string, state: string) { window.postMessage({ command: 'authResult', code: code, state: state }, '*'); + let handOffMessage = ('; ' + document.cookie).split('; ssoHandOffMessage=').pop().split(';').shift(); + document.cookie = 'ssoHandOffMessage=;SameSite=strict;max-age=0' + document.getElementById('content').innerHTML = + `

${handOffMessage}

`; } function extractFromRegex(s: string, regexString: string) { diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index c33f23fc39..35ab61958c 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -3193,6 +3193,9 @@ "enterpriseSingleSignOn": { "message": "Enterprise Single Sign-On" }, + "ssoHandOff": { + "message": "You may now close this tab and continue in the extension." + }, "businessPortal": { "message": "Business Portal", "description": "The web portal used by business organizations for configuring certain features."