From 24fd60ff713b0c7cd91f3530a0a79c206921a992 Mon Sep 17 00:00:00 2001 From: Balaji Jayaraman Date: Sun, 3 Nov 2024 23:33:01 +0530 Subject: [PATCH 1/2] Fix for custom attribute mapping --- .../lib/user-pool-idps/private/user-pool-idp-base.ts | 2 +- .../aws-cognito/test/user-pool-idps/amazon.test.ts | 4 ++-- .../aws-cdk-lib/aws-cognito/test/user-pool-idps/apple.test.ts | 4 ++-- .../aws-cdk-lib/aws-cognito/test/user-pool-idps/base.test.ts | 4 ++-- .../aws-cognito/test/user-pool-idps/facebook.test.ts | 4 ++-- .../aws-cognito/test/user-pool-idps/google.test.ts | 4 ++-- .../aws-cdk-lib/aws-cognito/test/user-pool-idps/oidc.test.ts | 4 ++-- .../aws-cdk-lib/aws-cognito/test/user-pool-idps/saml.test.ts | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/private/user-pool-idp-base.ts b/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/private/user-pool-idp-base.ts index 44f81cee1ba1d..a58fdf8611273 100644 --- a/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/private/user-pool-idp-base.ts +++ b/packages/aws-cdk-lib/aws-cognito/lib/user-pool-idps/private/user-pool-idp-base.ts @@ -30,7 +30,7 @@ export abstract class UserPoolIdentityProviderBase extends Resource implements I }, mapping); if (this.props.attributeMapping.custom) { mapping = Object.entries(this.props.attributeMapping.custom).reduce((agg, [k, v]) => { - return { ...agg, [k]: v.attributeName }; + return { ...agg, [k]: `custom:${v.attributeName}` }; }, mapping); } if (Object.keys(mapping).length === 0) { return undefined; } diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/amazon.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/amazon.test.ts index 1ecd8818d02e3..d959d8d0cf943 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/amazon.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/amazon.test.ts @@ -92,8 +92,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { given_name: 'name', address: 'amzn-address', - customAttr1: 'email', - customAttr2: 'amzn-custom-attr', + customAttr1: 'custom:email', + customAttr2: 'custom:amzn-custom-attr', }, }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/apple.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/apple.test.ts index 4c4d031fd04fc..ac9af84cb8271 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/apple.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/apple.test.ts @@ -105,8 +105,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { family_name: 'lastName', given_name: 'firstName', - customAttr1: 'email', - customAttr2: 'sub', + customAttr1: 'custom:email', + customAttr2: 'custom:sub', }, }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/base.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/base.test.ts index 1d58e96c572da..4246721cfbab6 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/base.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/base.test.ts @@ -67,8 +67,8 @@ describe('UserPoolIdentityProvider', () => { // THEN expect(idp.mapping).toStrictEqual({ - 'custom-attr-1': 'email', - 'custom-attr-2': 'name', + 'custom-attr-1': 'custom:email', + 'custom-attr-2': 'custom:name', }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/facebook.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/facebook.test.ts index 3c89f537d9410..dd5205ae00344 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/facebook.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/facebook.test.ts @@ -94,8 +94,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { given_name: 'name', address: 'fb-address', - customAttr1: 'email', - customAttr2: 'fb-custom-attr', + customAttr1: 'custom:email', + customAttr2: 'custom:fb-custom-attr', }, }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/google.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/google.test.ts index 13a62ea75aa80..c26ed179f4e6c 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/google.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/google.test.ts @@ -93,8 +93,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { given_name: 'name', address: 'google-address', - customAttr1: 'email', - customAttr2: 'google-custom-attr', + customAttr1: 'custom:email', + customAttr2: 'custom:google-custom-attr', }, }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/oidc.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/oidc.test.ts index 9e37c7a02e411..b7bdd3152b734 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/oidc.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/oidc.test.ts @@ -132,8 +132,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { family_name: 'family_name', given_name: 'given_name', - customAttr1: 'email', - customAttr2: 'sub', + customAttr1: 'custom:email', + customAttr2: 'custom:sub', }, }); }); diff --git a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/saml.test.ts b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/saml.test.ts index c4f2d97a4c19c..c51d9ccfe81ca 100644 --- a/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/saml.test.ts +++ b/packages/aws-cdk-lib/aws-cognito/test/user-pool-idps/saml.test.ts @@ -182,8 +182,8 @@ describe('UserPoolIdentityProvider', () => { AttributeMapping: { family_name: 'family_name', given_name: 'given_name', - customAttr1: 'email', - customAttr2: 'sub', + customAttr1: 'custom:email', + customAttr2: 'custom:sub', }, }); }); From 11780be9a3542430ea17b1e4dbcb6ec8256ffdb2 Mon Sep 17 00:00:00 2001 From: Balaji Jayaraman Date: Mon, 4 Nov 2024 01:39:36 +0530 Subject: [PATCH 2/2] update integration tests for google and amazon provider --- .../integ-user-pool-idp-amazon.template.json | 2 +- .../integ-user-pool-idp-google.template.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.amazon.js.snapshot/integ-user-pool-idp-amazon.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.amazon.js.snapshot/integ-user-pool-idp-amazon.template.json index 8b91b2d8d4900..9a48ec5e54db0 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.amazon.js.snapshot/integ-user-pool-idp-amazon.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.amazon.js.snapshot/integ-user-pool-idp-amazon.template.json @@ -75,7 +75,7 @@ "AttributeMapping": { "given_name": "name", "email": "email", - "userId": "user_id" + "userId": "custom:user_id" }, "ProviderDetails": { "client_id": "amzn-client-id", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.google.js.snapshot/integ-user-pool-idp-google.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.google.js.snapshot/integ-user-pool-idp-google.template.json index e4d451e68ee64..17735810499c9 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.google.js.snapshot/integ-user-pool-idp-google.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-idp.google.js.snapshot/integ-user-pool-idp-google.template.json @@ -90,7 +90,7 @@ "email": "email", "email_verified": "email_verified", "gender": "gender", - "names": "names" + "names": "custom:names" }, "ProviderDetails": { "client_id": "google-client-id",