1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-28 17:27:50 +01:00

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 <mdgibson@Matts-MBP.lan>
This commit is contained in:
Matt Gibson 2020-11-25 15:57:11 -06:00 committed by GitHub
parent 2db1684b3c
commit 6b66f14319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -19,9 +19,11 @@
<div class="mt-5 d-flex justify-content-center">
<div>
<img src="../images/logo-dark@2x.png" class="mb-4 logo" alt="Bitwarden">
<p class="text-center">
<i class="fa fa-spinner fa-spin fa-2x text-muted" title="Loading" aria-hidden="true"></i>
</p>
<div id="content">
<p class="text-center">
<i class="fa fa-spinner fa-spin fa-2x text-muted" title="Loading" aria-hidden="true"></i>
</p>
</div>
</div>
</div>
</body>

View File

@ -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 =
`<p>${handOffMessage}</p>`;
}
function extractFromRegex(s: string, regexString: string) {

View File

@ -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."