Skip to content

Commit

Permalink
fixing sha issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Aug 21, 2020
1 parent f6dddc1 commit 02b9536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ AWS.SingleSignOnCredentials = AWS.util.inherit(AWS.Credentials, {
}
AWS.config.update({ region: profile.sso_region });
const sso = new AWS.SSO();
if (!profile.sso_start_url) {
callback(new Error("No sso_start_url"));
return;
}

const fileName = `${sha1(profile.sso_start_url)}.json`;

Expand All @@ -52,18 +56,20 @@ AWS.SingleSignOnCredentials = AWS.util.inherit(AWS.Credentials, {
const cachedFile = fs.readFileSync(cachePath);
cacheObj = JSON.parse(cachedFile.toString());
}
const request = {
accessToken: cacheObj.accessToken,
accountId: profile.sso_account_id,
roleName: profile.sso_role_name,
};
if (!request) {

if (!cacheObj) {
throw AWS.util.error(
new Error(
`Cached credentials not found under ${cachePath}. Please make sure you log in with 'aws sso login' first`
)
);
}

const request = {
accessToken: cacheObj.accessToken,
accountId: profile.sso_account_id,
roleName: profile.sso_role_name,
};
sso.getRoleCredentials(request, (err, c) => {
if (!c) {
console.log(err.message);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mhlabs/aws-sdk-sso",
"version": "0.0.9",
"version": "0.0.10",
"description": "Credentials provider for AWS Single Sign-On",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 02b9536

Please sign in to comment.