Skip to content

Commit

Permalink
workaround for credentials chain issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Aug 16, 2020
1 parent 5dff044 commit eb5052a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
33 changes: 19 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@ AWS.SingleSignOnCredentials = AWS.util.inherit(AWS.Credentials, {
options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile;
},

init: function(options) {
const filepath =
process.env.AWS_CONFIG_FILE || path.join(os.homedir(), ".aws", "config");
var profiles = AWS.util.getProfilesFromSharedConfig(iniLoader, filepath);
var profile = profiles[this.profile] || {};
init: function (options) {
try {
const filepath =
process.env.AWS_CONFIG_FILE ||
path.join(os.homedir(), ".aws", "config");
var profiles = AWS.util.getProfilesFromSharedConfig(iniLoader, filepath);
var profile = profiles[this.profile] || {};

if (Object.keys(profile).length === 0) {
throw AWS.util.error(
new Error("Profile " + this.profile + " not found"),
{ code: "ProcessCredentialsProviderFailure" }
);
}
if (profile.sso_start_url) {
AWS.config.update({ credentials: new AWS.SingleSignOnCredentials() });
this.get((options || {}).callback || AWS.util.fn.noop);
if (Object.keys(profile).length === 0) {
throw AWS.util.error(
new Error("Profile " + this.profile + " not found"),
{ code: "ProcessCredentialsProviderFailure" }
);
}
if (profile.sso_start_url) {
AWS.config.update({ credentials: new AWS.SingleSignOnCredentials() });
this.get((options || {}).callback || AWS.util.fn.noop);
}
} catch (err) {
console.log(err);
}
},

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.5",
"version": "0.0.6",
"description": "Credentials provider for AWS Single Sign-On",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit eb5052a

Please sign in to comment.