Skip to content

Commit

Permalink
feat(cognito): support emailVerified attribute mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuaki640 committed Oct 3, 2024
1 parent 0c753c3 commit c17e064
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"Type": "AWS::Cognito::UserPoolIdentityProvider",
"Properties": {
"AttributeMapping": {
"phone_number": "phone_number"
"phone_number": "phone_number",
"email_verified": "email_verified"
},
"ProviderDetails": {
"client_id": "client-id",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ new UserPoolIdentityProviderOidc(stack, 'cdk', {
scopes: ['openid', 'phone'],
attributeMapping: {
phoneNumber: ProviderAttribute.other('phone_number'),
emailVerified: ProviderAttribute.other('email_verified'),
},
});

Expand Down
4 changes: 3 additions & 1 deletion packages/aws-cdk-lib/aws-cognito/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ new cognito.UserPoolIdentityProviderAmazon(this, 'Amazon', {
userPool: userpool,
attributeMapping: {
email: cognito.ProviderAttribute.AMAZON_EMAIL,
website: cognito.ProviderAttribute.other('url'), // use other() when an attribute is not pre-defined in the CDK
// use other() when an attribute is not pre-defined in the CDK
emailVerified: ProviderAttribute.other('email_verified'),
website: cognito.ProviderAttribute.other('url'),
custom: {
// custom user pool attributes go here
uniqueId: cognito.ProviderAttribute.AMAZON_USER_ID,
Expand Down
6 changes: 6 additions & 0 deletions packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export interface AttributeMapping {
*/
readonly email?: ProviderAttribute;

/**
* The user's e-mail address is verification.
* @default - not mapped
*/
readonly emailVerified?: ProviderAttribute;

/**
* The surname or last name of user.
* @default - not mapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ describe('UserPoolIdentityProvider', () => {
attributeMapping: {
givenName: ProviderAttribute.FACEBOOK_NAME,
birthdate: ProviderAttribute.FACEBOOK_BIRTHDAY,
emailVerified: ProviderAttribute.other('email_verified'),
},
});

// THEN
expect(idp.mapping).toStrictEqual({
given_name: 'name',
birthdate: 'birthday',
email_verified: 'email_verified',
});
});

Expand Down

0 comments on commit c17e064

Please sign in to comment.