From ea255334bc836fa09d6b86915df0592592a177b3 Mon Sep 17 00:00:00 2001 From: Balake Date: Sat, 8 Jun 2024 14:34:33 -0700 Subject: [PATCH] feat: Support SSO shortcut links (#24) * feat: Support SSO shortcut links * Fix spacing * More spacing fixes * Remove debug statement * Bump version * Govcloud support Co-authored-by: Mark Nielsen --------- Co-authored-by: Mark Nielsen --- containerize.js | 17 ++++++++++++++--- manifest.json | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/containerize.js b/containerize.js index 320aa21..2c2eeba 100644 --- a/containerize.js +++ b/containerize.js @@ -69,6 +69,8 @@ function listener(details) { let filter = browser.webRequest.filterResponseData(details.requestId); const queryString = new URL(details.url).searchParams; + const originParams = new URLSearchParams(details.originUrl.split('?').slice(1).join('?')); + // Parse some params for container name let accountRole = queryString.get("role_name"); let accountNumber = queryString.get("account_id"); @@ -93,7 +95,7 @@ function listener(details) { for (const [key, value] of Object.entries(params)) { name = name.replace(key, value); } - + let originDestination = originParams.get("destination"); let str = ''; let decoder = new TextDecoder("utf-8"); let encoder = new TextEncoder(); @@ -114,8 +116,17 @@ function listener(details) { // If we have a sign-in token, hijack this into a container if (object.signInToken) { let destination = object.destination; - if (!destination) { - destination = "https://console.aws.amazon.com"; + if (!originDestination) { + if (!object.destination) { + if (object.signInFederationLocation.includes("amazonaws-us-gov.com")) { + destination = "https://console.amazonaws-us-gov.com"; + } else { + destination = "https://console.aws.amazon.com"; + } + } + } + else { + destination = originDestination; } // Generate our federation URI and open it in a container diff --git a/manifest.json b/manifest.json index 932bb29..612da67 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "AWS SSO Containers", - "version": "1.8", + "version": "1.9", "description": "Automatically places AWS SSO calls into containers.", "browser_specific_settings": { "gecko": {