Skip to content

Commit 915b12d

Browse files
RanVakninRan Vaknin
andauthored
fix(credential-provider-ini): add DurationSeconds to assumeRole params (#4938)
Co-authored-by: Ran Vaknin <[email protected]>
1 parent 8cff4d9 commit 915b12d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/credential-provider-ini/src/resolveAssumeRoleCredentials.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
102102
role_arn: "mock_role_arn",
103103
role_session_name: "mock_role_session_name",
104104
external_id: "mock_external_id",
105+
duration_seconds: "2000",
105106
});
106107

107108
const getMockProfilesWithCredSource = (additionalData) => ({
@@ -176,6 +177,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
176177
RoleArn: mockRoleAssumeParams.role_arn,
177178
RoleSessionName: mockRoleAssumeParams.role_session_name,
178179
ExternalId: mockRoleAssumeParams.external_id,
180+
DurationSeconds: parseInt(mockRoleAssumeParams.duration_seconds),
179181
});
180182
});
181183

@@ -191,6 +193,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
191193
RoleArn: mockRoleAssumeParams.role_arn,
192194
RoleSessionName: mockRoleAssumeParams.role_session_name,
193195
ExternalId: mockRoleAssumeParams.external_id,
196+
DurationSeconds: parseInt(mockRoleAssumeParams.duration_seconds),
194197
});
195198
});
196199

@@ -207,6 +210,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
207210
RoleArn: mockRoleAssumeParams.role_arn,
208211
RoleSessionName: `aws-sdk-js-${mockDateNow}`,
209212
ExternalId: mockRoleAssumeParams.external_id,
213+
DurationSeconds: parseInt(mockRoleAssumeParams.duration_seconds),
210214
});
211215
});
212216

@@ -253,6 +257,7 @@ describe(resolveAssumeRoleCredentials.name, () => {
253257
ExternalId: mockRoleAssumeParams.external_id,
254258
SerialNumber: mockMfaSerial,
255259
TokenCode: mockTokenCode,
260+
DurationSeconds: parseInt(mockRoleAssumeParams.duration_seconds),
256261
});
257262
});
258263
});

packages/credential-provider-ini/src/resolveAssumeRoleCredentials.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export interface AssumeRoleParams {
3939
* The value provided by the MFA device.
4040
*/
4141
TokenCode?: string;
42+
43+
/**
44+
* The duration, in seconds, of the role session.
45+
*/
46+
DurationSeconds?: number;
4247
}
4348

4449
interface AssumeRoleWithSourceProfile extends Profile {
@@ -108,6 +113,7 @@ export const resolveAssumeRoleCredentials = async (
108113
RoleArn: data.role_arn!,
109114
RoleSessionName: data.role_session_name || `aws-sdk-js-${Date.now()}`,
110115
ExternalId: data.external_id,
116+
DurationSeconds: parseInt(data.duration_seconds || "3600", 10),
111117
};
112118

113119
const { mfa_serial } = data;

0 commit comments

Comments
 (0)