Skip to content

Commit

Permalink
feat: Support SSO shortcut links (#24)
Browse files Browse the repository at this point in the history
* feat: Support SSO shortcut links

* Fix spacing

* More spacing fixes

* Remove debug statement

* Bump version

* Govcloud support

Co-authored-by: Mark Nielsen <[email protected]>

---------

Co-authored-by: Mark Nielsen <[email protected]>
  • Loading branch information
blakemotl-RL and polothy authored Jun 8, 2024
1 parent b562345 commit ea25533
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions containerize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit ea25533

Please sign in to comment.