chore: Address PR comments 3
Signed-off-by: Carlos Esteban Lopez <lcarlosesteb@vmware.com>
This commit is contained in:
@@ -58,13 +58,10 @@ export const vmwareCloudAuthenticator = createOAuthAuthenticator<
|
||||
);
|
||||
}
|
||||
|
||||
const vmwareClaims = ['email', 'given_name', 'family_name', 'context_name'];
|
||||
|
||||
const identity = decodeJwt(input.session.idToken);
|
||||
const missingClaims = [
|
||||
'email',
|
||||
'given_name',
|
||||
'family_name',
|
||||
'context_name',
|
||||
].filter(key => !(key in identity));
|
||||
const missingClaims = vmwareClaims.filter(key => !(key in identity));
|
||||
|
||||
if (missingClaims.length > 0) {
|
||||
throw new Error(
|
||||
@@ -72,6 +69,16 @@ export const vmwareCloudAuthenticator = createOAuthAuthenticator<
|
||||
);
|
||||
}
|
||||
|
||||
const typeMismatchClaims = vmwareClaims.filter(
|
||||
key => typeof identity[key] !== 'string',
|
||||
);
|
||||
|
||||
if (typeMismatchClaims.length > 0) {
|
||||
throw new Error(
|
||||
`ID token claims type mismatch: ${typeMismatchClaims.join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (identity.context_name !== input.fullProfile.organizationId) {
|
||||
throw new Error(`ID token organizationId mismatch`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user