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

Allow overwriting STS config in ChainableTemporaryCredentials #2803

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "ChainableTemporaryCredentials",
"description": "Support for specifying STS client config when creating ChainableTemporaryCredentials to override endpoint or region."
}
12 changes: 8 additions & 4 deletions dist/aws-sdk-react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -17825,10 +17825,14 @@ return /******/ (function(modules) { // webpackBootstrap
this.tokenCodeFn = options.tokenCodeFn;
}
}
this.service = new STS({
params: params,
credentials: options.masterCredentials || AWS.config.credentials
});
config = AWS.util.merge(
{
params: params,
credentials: options.masterCredentials || AWS.config.credentials
},
options.stsConfig || {}
);
this.service = new STS(config);
},

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/credentials/chainable_temporary_credentials.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {AWSError} from '../error';
import STS = require('../../clients/sts');

export class ChainableTemporaryCredentials extends Credentials {
constructor(options: ChainableTemporaryCredentials.ChainableTemporaryCredentialsOptions, masterCredentials?: Credentials);
constructor(options: ChainableTemporaryCredentials.ChainableTemporaryCredentialsOptions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

/**
* Creates a new temporary credentials object.
*/
Expand All @@ -24,6 +24,7 @@ declare namespace ChainableTemporaryCredentials {
export type ChainableTemporaryCredentialsOptions = {
params?: STS.Types.AssumeRoleRequest|STS.Types.GetSessionTokenRequest,
masterCredentials?: Credentials,
stsConfig: STS.Types.ClientConfiguration,
tokenCodeFn?: (serialNumber: string, callback: (err?: Error, token?: string) => void) => void
}
}
12 changes: 8 additions & 4 deletions lib/credentials/chainable_temporary_credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ AWS.ChainableTemporaryCredentials = AWS.util.inherit(AWS.Credentials, {
this.tokenCodeFn = options.tokenCodeFn;
}
}
this.service = new STS({
params: params,
credentials: options.masterCredentials || AWS.config.credentials
});
config = AWS.util.merge(
{
params: params,
credentials: options.masterCredentials || AWS.config.credentials
},
options.stsConfig || {}
);
this.service = new STS(config);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@
"helper-test": "mocha scripts/lib/test-helper.spec.js",
"csm-functional-test": "mocha test/publisher/functional_test"
}
}
}
6 changes: 6 additions & 0 deletions test/credentials.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.