Skip to content

Commit

Permalink
Enable support for AWS temporary credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
BasitAli committed Dec 20, 2021
1 parent de971de commit 7c5025f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/nodes-base/credentials/Aws.credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ export class Aws implements ICredentialType {
password: true,
},
},
{
displayName: 'Temporary Credentials',
name: 'temporaryCredentials',
description: 'Support for temporary credentials from AWS STS',
type: 'boolean',
default: false,
},
{
displayName: 'Session Token',
name: 'sessionToken',
type: 'string',
displayOptions: {
show: {
temporaryCredentials: [
true,
],
},
},
default: '',
typeOptions: {
password: true,
},
},
{
displayName: 'Custom Endpoints',
name: 'customEndpoints',
Expand Down
7 changes: 6 additions & 1 deletion packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
// Sign AWS API request with the user credentials
const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body} as Request;

const securityHeaders = {
accessKeyId: `${credentials.accessKeyId}`.trim(),
secretAccessKey: `${credentials.secretAccessKey}`.trim(),
sessionToken: credentials.temporaryCredentials ? credentials.sessionToken.trim() : undefined
};

sign(signOpts, { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim()});
sign(signOpts, securityHeaders);

const options: OptionsWithUri = {
headers: signOpts.headers,
Expand Down

0 comments on commit 7c5025f

Please sign in to comment.