From 3bd14fc7dfada63fd8b00e19a22c3ea39263b363 Mon Sep 17 00:00:00 2001 From: Carlos Esteban Lopez Date: Wed, 22 Nov 2023 18:00:31 -0500 Subject: [PATCH] chore: Address PR comments 4 Signed-off-by: Carlos Esteban Lopez --- .../src/authenticator.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/auth-backend-module-vmware-cloud-provider/src/authenticator.ts b/plugins/auth-backend-module-vmware-cloud-provider/src/authenticator.ts index 3a64c4ffb1..4db4836f13 100644 --- a/plugins/auth-backend-module-vmware-cloud-provider/src/authenticator.ts +++ b/plugins/auth-backend-module-vmware-cloud-provider/src/authenticator.ts @@ -79,14 +79,20 @@ export const vmwareCloudAuthenticator = createOAuthAuthenticator< ); } - if (identity.context_name !== input.fullProfile.organizationId) { + // These claims were checked for presence & type + const { email, given_name, family_name, context_name } = identity as Record< + string, + string + >; + + if (context_name !== input.fullProfile.organizationId) { throw new Error(`ID token organizationId mismatch`); } return { profile: { - displayName: `${identity.given_name} ${identity.family_name}`, - email: identity.email as string, + displayName: `${given_name} ${family_name}`, + email, }, }; },