feat: Improve OIDC support for strict providers (#824)

This commit is contained in:
aleb_the_flash
2024-07-16 12:19:27 +02:00
committed by GitHub
parent 8d74cc1732
commit ad2966c5d6
5 changed files with 34 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ module.exports = {
},
exits: {
invalidUserInfoSignature: {},
invalidCodeOrNonce: {},
missingValues: {},
emailAlreadyInUse: {},
@@ -34,6 +35,10 @@ module.exports = {
);
userInfo = await client.userinfo(tokenSet);
} catch (e) {
if (e instanceof SyntaxError && e.message.includes('Unexpected token e in JSON at position 0')) {
sails.log.warn('Error while exchanging OIDC code: userInfo response is signed.');
throw 'invalidUserInfoSignature';
}
sails.log.warn(`Error while exchanging OIDC code: ${e}`);
throw 'invalidCodeOrNonce';
}