Commit 9644c0b
committed
fix(provider-awscloudformation): MFA role assumption fails with cached credentials after v14.2.2.
This commit fixes three related bugs in the credential caching logic for
MFA-based role assumption that were introduced in commit 04f7bcf
(PR aws-amplify#14315 "fix: role assumption through profiles not working properly").
Bug 1: MFA prompt never appears
----------------------------------------
getCachedRoleCredentials() always returned an object `{ credentials: {} }`
even when no valid cached credentials existed. This caused the check
`if (!roleCredentials)` in getRoleCredentials() to always be false,
so the STS AssumeRole call with MFA token was never executed.
Fix: Return undefined when no valid cached credentials exist.
Bug 2: Credential cache validation always fails
----------------------------------------
Credentials were cached in nested format `{ credentials: { accessKeyId, ... } }`
but validateCachedCredentials() expected flat format `{ accessKeyId, ... }`.
This caused cache validation to always fail, prompting for MFA on every call.
Fix: Cache the flat credentials object (roleCredentials.credentials) instead
of the nested wrapper.
Bug 3: "identity.expiration.getTime is not a function" error
----------------------------------------
When credentials are read from the JSON cache file, the Date object for
expiration is deserialized as a string. The AWS SDK's @smithy/core module
calls expiration.getTime() which fails on a string.
The fix in PR aws-amplify#14315 only addressed this in getConfiguredAWSClientConfig(),
but getProfiledAwsConfig() is called directly during env checkout without
going through that code path.
Fix: Convert expiration to Date when returning cached credentials.1 parent f1edf0b commit 9644c0b
1 file changed
Lines changed: 6 additions & 1 deletion
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
248 | 251 | | |
249 | 252 | | |
250 | 253 | | |
| 254 | + | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
0 commit comments