Skip to content

Commit

Permalink
Fix encoding uri for JIT credential refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
mmurrell-r7 committed Jun 28, 2024
1 parent 1369939 commit d7f8360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/main/containers/refresh-jit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ async function refreshJitCallback(profileName, session) {
let creds = {};
let response;
try {
response = await fetch(session.apiUri, {
response = await fetch(encodeURI(session.apiUri), {
method: 'GET',
headers: session.header,
});
} catch (err) {
console.error(err); // eslint-disable-line no-console
Manager.removeByName(profileName);
throw new Error('AWSAML is unable to fetch credentials from ICS');
throw new Error(`AWSAML is unable to fetch credentials from ICS. HTTPS request to URI: ${session.apiUri}`);
}

if (response.ok) {
Expand Down Expand Up @@ -61,7 +61,7 @@ async function refreshJit(session) {
r = new Reloader({
name: profileName,
async callback() {
await refreshJitCallback(profileName, session);
await refreshJitCallback(profileName, session).catch(e => console.log(e));

Check failure on line 64 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Expected parentheses around arrow function argument

Check warning on line 64 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Unexpected console statement

Check failure on line 64 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Expected parentheses around arrow function argument

Check warning on line 64 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Unexpected console statement
},
interval: (session.duration / 2) * 1000,
role: session.roleConfigId,
Expand All @@ -73,14 +73,14 @@ async function refreshJit(session) {
r.role = session.roleConfigId;
r.setCallback(
async () => {
await refreshJitCallback(profileName, session);
await refreshJitCallback(profileName, session).catch(e => console.log(e));

Check failure on line 76 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Expected parentheses around arrow function argument

Check warning on line 76 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Unexpected console statement

Check failure on line 76 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Expected parentheses around arrow function argument

Check warning on line 76 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Unexpected console statement
},
);
r.role = session.roleConfigId;
}
r.restart();
}
return refreshJitCallback(profileName, session);
return refreshJitCallback(profileName, session).catch(e => console.log(e));

Check failure on line 83 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Expected parentheses around arrow function argument

Check warning on line 83 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Unexpected console statement

Check failure on line 83 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Expected parentheses around arrow function argument

Check warning on line 83 in src/main/containers/refresh-jit.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Unexpected console statement
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function registerHandlers() {

let data;
try {
data = await refreshJit(encodeURI(profile));
data = await refreshJit(profile);
} catch (err) {
const errBody = JSON.stringify({
error_message: err?.message || 'unknown',
Expand Down

0 comments on commit d7f8360

Please sign in to comment.