fix(core): Fix OAuth2 callback for grantType=clientCredentials (#6500)

Co-authored-by: agobrech <ael.gobrecht@gmail.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-06-21 12:25:27 +02:00 committed by GitHub
parent 1cf36e1ed6
commit 25b92169ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,24 +272,19 @@ oauth2CredentialController.get(
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
};
if ((get(oauthCredentials, 'authentication', 'header') as string) === 'body') {
if (oauthCredentials.grantType === 'pkce') {
options = {
body: { code_verifier: decryptedDataOriginal.codeVerifier },
};
} else if ((get(oauthCredentials, 'authentication', 'header') as string) === 'body') {
options = {
body: {
...(oauthCredentials.grantType === 'pkce' && {
code_verifier: decryptedDataOriginal.codeVerifier,
}),
...(oauthCredentials.grantType === 'authorizationCode' && {
client_id: get(oauthCredentials, 'clientId') as string,
client_secret: get(oauthCredentials, 'clientSecret', '') as string,
}),
client_id: get(oauthCredentials, 'clientId') as string,
client_secret: get(oauthCredentials, 'clientSecret', '') as string,
},
};
// @ts-ignore
delete oAuth2Parameters.clientSecret;
} else if (oauthCredentials.grantType === 'pkce') {
options = {
body: { code_verifier: decryptedDataOriginal.codeVerifier },
};
}
await Container.get(ExternalHooks).run('oauth2.callback', [oAuth2Parameters]);