Skip to content

Commit 667ebef

Browse files
author
Rick Song
committed
Includes session token if provided to client initialization.
If you're using Temporary Credentials with AWS STS, you must include a session token. Reference: http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/prog-services-sts.html
1 parent bfa3c68 commit 667ebef

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ For detailed information on how configuration of plugins works, please refer to
6565

6666
### accessKeyId
6767

68-
The AWS access key for the user that has the ability to upload to the `bucket`. If this is left undefined,
68+
The AWS access key for the user that has the ability to upload to the `bucket`. If this is left undefined,
6969
the normal [AWS SDK credential resolution][5] will take place.
7070

7171
*Default:* `undefined`
@@ -76,6 +76,13 @@ The AWS secret for the user that has the ability to upload to the `bucket`. This
7676

7777
*Default:* `undefined`
7878

79+
### sessionToken
80+
81+
The AWS session token for the user that has the ability to upload to the `bucket`. This may be required if you are using the [AWS Security Token Service][6].
82+
This requires both `accessKeyId` and `secretAccessKey` to be defined.
83+
84+
*Default:* `undefined`
85+
7986
### bucket (`required`)
8087

8188
The AWS bucket that the files will be uploaded to.
@@ -216,7 +223,7 @@ To properly serve certain assets (i.e. webfonts) a basic CORS configuration is n
216223

217224
Replace **http://www.your-site.com** with your domain.
218225

219-
Some more info: [Amazon CORS guide][6], [Stackoverflow][7]
226+
Some more info: [Amazon CORS guide][7], [Stackoverflow][8]
220227

221228

222229
## Running Tests
@@ -228,5 +235,6 @@ Some more info: [Amazon CORS guide][6], [Stackoverflow][7]
228235
[3]: https://github.com/lukemelia/ember-cli-deploy-gzip "ember-cli-deploy-gzip"
229236
[4]: https://github.com/lukemelia/ember-cli-deploy-manifest "ember-cli-deploy-manifest"
230237
[5]: https://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Setting_AWS_Credentials "Setting AWS Credentials"
231-
[6]: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html "Amazon CORS guide"
232-
[7]: http://stackoverflow.com/questions/12229844/amazon-s3-cors-cross-origin-resource-sharing-and-firefox-cross-domain-font-loa?answertab=votes#tab-top "Stackoverflow"
238+
[6]: http://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html "AWS Security Token Service guide"
239+
[7]: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html "Amazon CORS guide"
240+
[8]: http://stackoverflow.com/questions/12229844/amazon-s3-cors-cross-origin-resource-sharing-and-firefox-cross-domain-font-loa?answertab=votes#tab-top "Stackoverflow"

lib/s3.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ module.exports = CoreObject.extend({
1515
var s3Options = {
1616
region: this._plugin.readConfig('region')
1717
};
18+
1819
const accessKeyId = this._plugin.readConfig('accessKeyId');
1920
const secretAccessKey = this._plugin.readConfig('secretAccessKey');
21+
const sessionToken = this._plugin.readConfig('sessionToken');
2022

2123
if (accessKeyId && secretAccessKey) {
2224
this._plugin.log('Using AWS access key id and secret access key from config', { verbose: true });
2325
s3Options.accessKeyId = accessKeyId;
2426
s3Options.secretAccessKey = secretAccessKey;
2527
}
28+
29+
if (sessionToken) {
30+
this._plugin.log('Using AWS session token from config', { verbose: true });
31+
s3Options.sessionToken = sessionToken;
32+
}
33+
2634
this._client = this._plugin.readConfig('s3Client') || new AWS.S3(s3Options);
2735
},
2836

tests/unit/index-nodetest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('s3 plugin', function() {
3535
s3: {
3636
accessKeyId: 'aaaa',
3737
secretAccessKey: 'bbbb',
38+
sessionToken: 'eeee',
3839
bucket: 'cccc',
3940
region: 'dddd',
4041
filePattern: '*.{css,js}',

0 commit comments

Comments
 (0)