Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
add some comments and clearer naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Jun 29, 2022
1 parent b226359 commit 9b7c401
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/teleport/src/AppLauncher/useAppLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ function resolveRedirectUrl(params: UrlLauncherParams) {
const location = window.location;
const port = location.port ? ':' + location.port : '';
const state = getUrlParameter('state', location.search);
const path = getUrlParameter('path', location.search);
const arn = getUrlParameter('awsrole', location.search);
/*
capture and pass any requested App Access path during the `x-teleport-auth` process
*/
const redirectPath = getUrlParameter('path', location.search);

// no state value: let the target app know of a new auth exchange
if (!state) {
Expand All @@ -60,11 +63,11 @@ function resolveRedirectUrl(params: UrlLauncherParams) {
if (params.publicAddr) {
url.searchParams.set('addr', params.publicAddr);
}
if (params.arn) {
url.searchParams.set('awsrole', decodeURIComponent(params.arn));
if (arn) {
url.searchParams.set('awsrole', decodeURIComponent(arn));
}
if (path) {
url.searchParams.set('path', path);
if (redirectPath) {
url.searchParams.set('path', redirectPath);
}
return url.toString();
});
Expand All @@ -78,8 +81,8 @@ function resolveRedirectUrl(params: UrlLauncherParams) {
const url = new URL(`https://${result.fqdn}${port}/x-teleport-auth`);
url.searchParams.set('state', state);
url.hash = `#value=${result.value}`;
if (path) {
url.searchParams.set('path', path);
if (redirectPath) {
url.searchParams.set('path', redirectPath);
}
return url.toString();
});
Expand Down

0 comments on commit 9b7c401

Please sign in to comment.