Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Includes session token if provided to client initialization. #57

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For detailed information on how configuration of plugins works, please refer to

### accessKeyId

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

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

*Default:* `undefined`

### sessionToken

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].
This requires both `accessKeyId` and `secretAccessKey` to be defined.

*Default:* `undefined`

### bucket (`required`)

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

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

Some more info: [Amazon CORS guide][6], [Stackoverflow][7]
Some more info: [Amazon CORS guide][7], [Stackoverflow][8]


## Running Tests
Expand All @@ -228,5 +235,6 @@ Some more info: [Amazon CORS guide][6], [Stackoverflow][7]
[3]: https://github.com/lukemelia/ember-cli-deploy-gzip "ember-cli-deploy-gzip"
[4]: https://github.com/lukemelia/ember-cli-deploy-manifest "ember-cli-deploy-manifest"
[5]: https://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Setting_AWS_Credentials "Setting AWS Credentials"
[6]: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html "Amazon CORS guide"
[7]: http://stackoverflow.com/questions/12229844/amazon-s3-cors-cross-origin-resource-sharing-and-firefox-cross-domain-font-loa?answertab=votes#tab-top "Stackoverflow"
[6]: http://docs.aws.amazon.com/STS/latest/APIReference/Welcome.html "AWS Security Token Service guide"
[7]: http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html "Amazon CORS guide"
[8]: http://stackoverflow.com/questions/12229844/amazon-s3-cors-cross-origin-resource-sharing-and-firefox-cross-domain-font-loa?answertab=votes#tab-top "Stackoverflow"
8 changes: 8 additions & 0 deletions lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ module.exports = CoreObject.extend({
var s3Options = {
region: this._plugin.readConfig('region')
};

const accessKeyId = this._plugin.readConfig('accessKeyId');
const secretAccessKey = this._plugin.readConfig('secretAccessKey');
const sessionToken = this._plugin.readConfig('sessionToken');

if (accessKeyId && secretAccessKey) {
this._plugin.log('Using AWS access key id and secret access key from config', { verbose: true });
s3Options.accessKeyId = accessKeyId;
s3Options.secretAccessKey = secretAccessKey;
}

if (sessionToken) {
this._plugin.log('Using AWS session token from config', { verbose: true });
s3Options.sessionToken = sessionToken;
}

this._client = this._plugin.readConfig('s3Client') || new AWS.S3(s3Options);
},

Expand Down
1 change: 1 addition & 0 deletions tests/unit/index-nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('s3 plugin', function() {
s3: {
accessKeyId: 'aaaa',
secretAccessKey: 'bbbb',
sessionToken: 'eeee',
bucket: 'cccc',
region: 'dddd',
filePattern: '*.{css,js}',
Expand Down