Skip to content

Commit 24fb3cf

Browse files
author
Niranjan Jayakar
committed
rename mfa
1 parent 7a2ff56 commit 24fb3cf

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

packages/@aws-cdk/aws-cognito/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ configure an MFA token and use it for sign in. It also allows for the users to u
188188
```ts
189189
new UserPool(this, 'myuserpool', {
190190
// ...
191-
mfaEnforcement: MfaEnforcement.REQUIRED,
192-
mfaToken: {
191+
mfa: Mfa.REQUIRED,
192+
mfaSecondFactor: {
193193
sms: true,
194194
otp: true,
195195
},

packages/@aws-cdk/aws-cognito/lib/user-pool.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export interface UserInvitationConfig {
307307
* The different ways in which a user pool's MFA enforcement can be configured.
308308
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-mfa.html
309309
*/
310-
export enum MfaEnforcement {
310+
export enum Mfa {
311311
/** Users are not required to use MFA for sign in, and cannot configure one. */
312312
OFF = 'OFF',
313313
/** Users are not required to use MFA for sign in, but can configure one if they so choose to. */
@@ -320,7 +320,7 @@ export enum MfaEnforcement {
320320
* The different ways in which a user pool can obtain their MFA token for sign in.
321321
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-mfa.html
322322
*/
323-
export interface MfaTypes {
323+
export interface MfaSecondFactor {
324324
/**
325325
* The MFA token is sent to the user via SMS to their verified phone numbers
326326
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-mfa-sms-text-message.html
@@ -468,17 +468,17 @@ export interface UserPoolProps {
468468
/**
469469
* Configure on whether users of this user pool can or are required use MFA to sign in.
470470
*
471-
* @default MfaEnforcement.OFF
471+
* @default Mfa.OFF
472472
*/
473-
readonly mfaEnforcement?: MfaEnforcement;
473+
readonly mfa?: Mfa;
474474

475475
/**
476476
* Configure the MFA types that users can use in this user pool. Ignored if `mfaEnforcement` is set to `OFF`.
477477
*
478478
* @default - { sms: true, oneTimePassword: false }, if `mfaEnforcement` is set to `OPTIONAL` or `REQUIRED`.
479479
* { sms: false, oneTimePassword: false }, otherwise
480480
*/
481-
readonly mfaTypes?: MfaTypes;
481+
readonly mfaSecondFactor?: MfaSecondFactor;
482482

483483
/**
484484
* Password policy for this user pool.
@@ -629,7 +629,7 @@ export class UserPool extends Resource implements IUserPool {
629629
emailVerificationSubject,
630630
smsVerificationMessage,
631631
verificationMessageTemplate,
632-
mfaConfiguration: props.mfaEnforcement,
632+
mfaConfiguration: props.mfa,
633633
enabledMfas: this.mfaConfiguration(props),
634634
policies: passwordPolicy !== undefined ? { passwordPolicy } : undefined,
635635
emailConfiguration: undefinedIfNoKeys({
@@ -837,18 +837,18 @@ export class UserPool extends Resource implements IUserPool {
837837
}
838838

839839
private mfaConfiguration(props: UserPoolProps): string[] | undefined {
840-
if (props.mfaEnforcement === undefined || props.mfaEnforcement === MfaEnforcement.OFF) {
840+
if (props.mfa === undefined || props.mfa === Mfa.OFF) {
841841
// since default is OFF, treat undefined and OFF the same way
842842
return undefined;
843-
} else if (props.mfaTypes === undefined &&
844-
(props.mfaEnforcement === MfaEnforcement.OPTIONAL || props.mfaEnforcement === MfaEnforcement.REQUIRED)) {
843+
} else if (props.mfaSecondFactor === undefined &&
844+
(props.mfa === Mfa.OPTIONAL || props.mfa === Mfa.REQUIRED)) {
845845
return [ 'SMS_MFA' ];
846846
} else {
847847
const enabledMfas = [];
848-
if (props.mfaTypes!.sms) {
848+
if (props.mfaSecondFactor!.sms) {
849849
enabledMfas.push('SMS_MFA');
850850
}
851-
if (props.mfaTypes!.otp) {
851+
if (props.mfaSecondFactor!.otp) {
852852
enabledMfas.push('SOFTWARE_TOKEN_MFA');
853853
}
854854
return enabledMfas;

packages/@aws-cdk/aws-cognito/test/integ.user-pool-explicit-props.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { App, Duration, Stack } from '@aws-cdk/core';
2-
import { MfaEnforcement, UserPool } from '../lib';
2+
import { Mfa, UserPool } from '../lib';
33

44
const app = new App();
55
const stack = new Stack(app, 'integ-user-pool');
@@ -25,8 +25,8 @@ new UserPool(stack, 'myuserpool', {
2525
email: true,
2626
phone: true,
2727
},
28-
mfaEnforcement: MfaEnforcement.REQUIRED,
29-
mfaTypes: {
28+
mfa: Mfa.REQUIRED,
29+
mfaSecondFactor: {
3030
sms: true,
3131
otp: true,
3232
},

packages/@aws-cdk/aws-cognito/test/user-pool.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ABSENT } from '@aws-cdk/assert/lib/assertions/have-resource';
33
import { Role } from '@aws-cdk/aws-iam';
44
import * as lambda from '@aws-cdk/aws-lambda';
55
import { Duration, Stack, Tag } from '@aws-cdk/core';
6-
import { MfaEnforcement, UserPool, VerificationEmailStyle } from '../lib';
6+
import { Mfa, UserPool, VerificationEmailStyle } from '../lib';
77

88
describe('User Pool', () => {
99
test('default setup', () => {
@@ -444,15 +444,15 @@ describe('User Pool', () => {
444444
// WHEN
445445
new UserPool(stack, 'Pool1', {
446446
userPoolName: 'Pool1',
447-
mfaTypes: {
447+
mfaSecondFactor: {
448448
sms: true,
449449
otp: true,
450450
}
451451
});
452452
new UserPool(stack, 'Pool2', {
453453
userPoolName: 'Pool2',
454-
mfaEnforcement: MfaEnforcement.OFF,
455-
mfaTypes: {
454+
mfa: Mfa.OFF,
455+
mfaSecondFactor: {
456456
sms: true,
457457
otp: true,
458458
}
@@ -478,11 +478,11 @@ describe('User Pool', () => {
478478
// WHEN
479479
new UserPool(stack, 'Pool1', {
480480
userPoolName: 'Pool1',
481-
mfaEnforcement: MfaEnforcement.OPTIONAL,
481+
mfa: Mfa.OPTIONAL,
482482
});
483483
new UserPool(stack, 'Pool2', {
484484
userPoolName: 'Pool2',
485-
mfaEnforcement: MfaEnforcement.REQUIRED,
485+
mfa: Mfa.REQUIRED,
486486
});
487487

488488
// THEN
@@ -504,8 +504,8 @@ describe('User Pool', () => {
504504

505505
// WHEN
506506
new UserPool(stack, 'Pool', {
507-
mfaEnforcement: MfaEnforcement.REQUIRED,
508-
mfaTypes: {
507+
mfa: Mfa.REQUIRED,
508+
mfaSecondFactor: {
509509
sms: true,
510510
otp: true,
511511
}

0 commit comments

Comments
 (0)