mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(cloudformation): keep SMS_MFA on a user pool update until MFA is turned off (#7088)
* fix(cloudformation): keep SMS_MFA on a user pool update until MFA is turned off The AWS::Cognito::UserPool reference says that once SMS_MFA is enabled, only MfaConfiguration OFF turns it off. An update that stopped listing SMS_MFA in EnabledMfas cleared it. replaceUserPoolMfaConfig now keeps the pool's SMS setting when none is given and the mode is not OFF. Closes #7086 * fix(cognito): keep SMS MFA with the pool's current SMS settings Keeping SMS MFA replayed the settings it was enabled with, so an update that dropped SMS_MFA and changed SmsAuthenticationMessage or SmsConfiguration put the old values back over the ones updateUserPool had just applied. The kept SMS MFA now takes the pool's current message and SMS configuration.
This commit is contained in:
1 parent
3acebc90fe
commit
f0a1b11385
5 files changed
+61
-2
No files matched your search
@@ -850,6 +850,10 @@ public class CognitoService implements ResourceProvider {
|
||||
* how CloudFormation applies a user pool's EnabledMfas. The settings are built on a copy and
|
||||
* stored in one write, so a concurrent sign-in never reads the pool between its old and new
|
||||
* MFA settings, and under the pool lock, so a concurrent tag or update is kept.
|
||||
* SMS is the exception: once enabled, only MfaConfiguration OFF turns it off, as the
|
||||
* AWS::Cognito::UserPool reference documents, so an SMS setting that is not given is kept,
|
||||
* with the pool's current message and SMS configuration rather than the ones it was enabled
|
||||
* with, since an update may have just changed them.
|
||||
*/
|
||||
public UserPool replaceUserPoolMfaConfig(String id, String mfaConfiguration,
|
||||
Boolean softwareTokenMfaEnabled,
|
||||
@@ -857,6 +861,16 @@ public class CognitoService implements ResourceProvider {
|
||||
Map<String, Object> emailMfaConfiguration) {
|
||||
synchronized (poolLock(id)) {
|
||||
UserPool pool = MAPPER.convertValue(describeUserPool(id), UserPool.class);
|
||||
if (smsMfaConfiguration == null && mfaConfiguration != null && !"OFF".equals(mfaConfiguration)
|
||||
&& pool.getSmsMfaConfiguration() != null) {
|
||||
smsMfaConfiguration = new LinkedHashMap<>(pool.getSmsMfaConfiguration());
|
||||
if (pool.getSmsAuthenticationMessage() != null) {
|
||||
smsMfaConfiguration.put("SmsAuthenticationMessage", pool.getSmsAuthenticationMessage());
|
||||
}
|
||||
if (pool.getSmsConfiguration() != null) {
|
||||
smsMfaConfiguration.put("SmsConfiguration", pool.getSmsConfiguration());
|
||||
}
|
||||
}
|
||||
applyMfaConfig(pool, mfaConfiguration, softwareTokenMfaEnabled, smsMfaConfiguration,
|
||||
emailMfaConfiguration, null, true);
|
||||
poolStore.put(id, pool);
|
||||
|
||||
Reference in new issue
Block a user