From 98889fcf371d7bcfb9862497fbaf6ad8be3d1684 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:40:01 -0400 Subject: [PATCH 1/8] Parse JSON return --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c3d1464..04304c8 100644 --- a/index.js +++ b/index.js @@ -51,12 +51,12 @@ const getTemporaryCredentials = (config, callback) => { }, err => { if (err) return callback(err, null); - return callback(null, newCredentials); + return callback(null, JSON.parse(newCredentials)); } ); }); } else { - return callback(null, old); + return callback(null, JSON.parse(old)); } }); }; From 86d225d4b65495e62a88d68306dbae11bd632d07 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:40:37 -0400 Subject: [PATCH 2/8] Update README to reflect JSON parse occuring in library, and readibility --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ca9dffb..e8f9622 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Available variables and their usage: | AWS_STS_ACCESS_SECRET | | Equivalent to `AWS_SECRET_ACCESS_KEY`. Used to generate credentials suitable to assume a specific role and the policies associated with it. | | AWS_ROLE_ARN | | The Role to assume in ARN format| | AWS_ROLE_SESSION_NAME | `temporary` | A name that will be assigned to the temporary credentials | -| AWS_STS_FILE_NAME | `./.aws-sts.json` | Used to store credentials in JSON format, fully qualified path to credential file, JSON | +| AWS_STS_FILE_NAME | `./.aws-sts.json` | Used to store credentials in JSON format, fully qualified path to credential file| | AWS_ROLE_DURATION_SECONDS | 43200 | Number of seconds the temporary access key lasts| | AWS_STS_FILE_MODE | 0o600 | Permissions setting on JSON file that caches credentials, (600 is user read-write only) | @@ -47,17 +47,16 @@ sts.getTemporaryCredentials({ secret: 'secret key paired to access key' } } -}, (err, awsRaw) => { +}, (err, temp) => { if (err) { console.log('err:',err); process.exit(-1); } - var aws = JSON.parse(awsRaw); - console.log('aws:',aws); - var sh = `AWS_ACCESS_KEY_ID=${aws.Credentials.AccessKeyId}\n` + - `AWS_SECRET_ACCESS_KEY=${aws.Credentials.SecretAccessKey}\n` + - `AWS_SESSION_TOKEN=${aws.Credentials.SessionToken}\n`; + console.log('temp:',temp); + var sh = `export AWS_ACCESS_KEY_ID=${temp.Credentials.AccessKeyId}\n` + + `export AWS_SECRET_ACCESS_KEY=${temp.Credentials.SecretAccessKey}\n` + + `export AWS_SESSION_TOKEN=${temp.Credentials.SessionToken}\n`; fs.writeFileSync("aws-temp-credentials.sh", sh, {encoding:'utf-8'}); }); ``` From 7ab9ac6cc3e6cfeb0846d8e0abe8be7b8b9f0792 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:44:45 -0400 Subject: [PATCH 3/8] highlight numbers --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8f9622..fb9a088 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Available variables and their usage: | AWS_ROLE_ARN | | The Role to assume in ARN format| | AWS_ROLE_SESSION_NAME | `temporary` | A name that will be assigned to the temporary credentials | | AWS_STS_FILE_NAME | `./.aws-sts.json` | Used to store credentials in JSON format, fully qualified path to credential file| -| AWS_ROLE_DURATION_SECONDS | 43200 | Number of seconds the temporary access key lasts| -| AWS_STS_FILE_MODE | 0o600 | Permissions setting on JSON file that caches credentials, (600 is user read-write only) | +| AWS_ROLE_DURATION_SECONDS | `43200` | Number of seconds the temporary access key lasts| +| AWS_STS_FILE_MODE | `0o600` | Permissions setting on JSON file that caches credentials, (600 is user read-write only) | These values can be passed either in the environment or in a configuration object, with environment variables overriding any passed in configuration. From b6a119f67e2d3391ac02011c40f295289ed4b803 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:45:46 -0400 Subject: [PATCH 4/8] Better formatting in example --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb9a088..2b64d39 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ sts.getTemporaryCredentials({ } console.log('temp:',temp); - var sh = `export AWS_ACCESS_KEY_ID=${temp.Credentials.AccessKeyId}\n` + + var sh = + `export AWS_ACCESS_KEY_ID=${temp.Credentials.AccessKeyId}\n` + `export AWS_SECRET_ACCESS_KEY=${temp.Credentials.SecretAccessKey}\n` + `export AWS_SESSION_TOKEN=${temp.Credentials.SessionToken}\n`; fs.writeFileSync("aws-temp-credentials.sh", sh, {encoding:'utf-8'}); From c6cc2f34ebd8d883407b83032a6dbe86ba11cb23 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:48:14 -0400 Subject: [PATCH 5/8] Add keywords --- package.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 69cb0d6..a644369 100644 --- a/package.json +++ b/package.json @@ -19,5 +19,15 @@ }, "dependencies": { "aws-sdk": "~2.166.0" - } + }, + "keywords": [ + "aws", + "sts", + "aws-sdk", + "aws-sts", + "roles", + "policy", + "token", + "security" + ] } From b8a72670a548f08ccad49c4750e8620e0aad71ac Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:48:42 -0400 Subject: [PATCH 6/8] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a644369..9e287e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aws-sts-helper", - "version": "1.0.0", + "version": "1.0.1", "description": "Facilitates gathering temporary security tokens from the AWS STS (Security Token Service) and then using that token information for interacting with AWS APIs", "repository": { "type": "git", From 4e95f5299f728a78b74f8ad12d86da76405c61f7 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:58:33 -0400 Subject: [PATCH 7/8] missing comma --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 04304c8..fd24219 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,7 @@ const getTemporaryCredentials = (config, callback) => { }, role: { arn: process.env.AWS_ROLE_ARN || '', - sessionName: process.env.AWS_ROLE_SESSION_NAME || 'temporary' + sessionName: process.env.AWS_ROLE_SESSION_NAME || 'temporary', durationSeconds: process.env.AWS_ROLE_DURATION_SECONDS || 43200 }, key: { From 1ea2244be7b389a30a476b7628999b48a076e336 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Thu, 16 Aug 2018 08:59:08 -0400 Subject: [PATCH 8/8] 1.0.2 - fix comma syntax error --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e287e1..b223e52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aws-sts-helper", - "version": "1.0.1", + "version": "1.0.2", "description": "Facilitates gathering temporary security tokens from the AWS STS (Security Token Service) and then using that token information for interacting with AWS APIs", "repository": { "type": "git",