Skip to content

Commit 880c67b

Browse files
committed
Merge pull request #57 from RickCSong/ricksong/add-session-token-to-initialization
Includes session token if provided to client initialization.
2 parents f5eacf0 + 667ebef commit 880c67b

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.
@@ -217,7 +224,7 @@ To properly serve certain assets (i.e. webfonts) a basic CORS configuration is n
217224

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

220-
Some more info: [Amazon CORS guide][6], [Stackoverflow][7]
227+
Some more info: [Amazon CORS guide][7], [Stackoverflow][8]
221228

222229

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