mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-10 19:26:49 +02:00
fix: send id_token in OAuth2 requests (#223)
This commit is contained in:
committed by
GitHub
parent
6eb16afd96
commit
eb5ef7d7d5
@@ -303,6 +303,7 @@ export const plugin: PluginDefinition = {
|
|||||||
const headerPrefix = stringArg(values, 'headerPrefix');
|
const headerPrefix = stringArg(values, 'headerPrefix');
|
||||||
const grantType = stringArg(values, 'grantType') as GrantType;
|
const grantType = stringArg(values, 'grantType') as GrantType;
|
||||||
const credentialsInBody = values.credentials === 'body';
|
const credentialsInBody = values.credentials === 'body';
|
||||||
|
const tokenName = values.tokenName === 'id_token' ? 'id_token' : 'access_token';
|
||||||
|
|
||||||
let token: AccessToken;
|
let token: AccessToken;
|
||||||
if (grantType === 'authorization_code') {
|
if (grantType === 'authorization_code') {
|
||||||
@@ -328,7 +329,7 @@ export const plugin: PluginDefinition = {
|
|||||||
codeVerifier: stringArgOrNull(values, 'pkceCodeVerifier'),
|
codeVerifier: stringArgOrNull(values, 'pkceCodeVerifier'),
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
tokenName: values.tokenName === 'id_token' ? 'id_token' : 'access_token',
|
tokenName: tokenName,
|
||||||
});
|
});
|
||||||
} else if (grantType === 'implicit') {
|
} else if (grantType === 'implicit') {
|
||||||
const authorizationUrl = stringArg(values, 'authorizationUrl');
|
const authorizationUrl = stringArg(values, 'authorizationUrl');
|
||||||
@@ -342,7 +343,7 @@ export const plugin: PluginDefinition = {
|
|||||||
scope: stringArgOrNull(values, 'scope'),
|
scope: stringArgOrNull(values, 'scope'),
|
||||||
audience: stringArgOrNull(values, 'audience'),
|
audience: stringArgOrNull(values, 'audience'),
|
||||||
state: stringArgOrNull(values, 'state'),
|
state: stringArgOrNull(values, 'state'),
|
||||||
tokenName: values.tokenName === 'id_token' ? 'id_token' : 'access_token',
|
tokenName: tokenName,
|
||||||
});
|
});
|
||||||
} else if (grantType === 'client_credentials') {
|
} else if (grantType === 'client_credentials') {
|
||||||
const accessTokenUrl = stringArg(values, 'accessTokenUrl');
|
const accessTokenUrl = stringArg(values, 'accessTokenUrl');
|
||||||
@@ -374,7 +375,7 @@ export const plugin: PluginDefinition = {
|
|||||||
throw new Error('Invalid grant type ' + grantType);
|
throw new Error('Invalid grant type ' + grantType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerValue = `${headerPrefix} ${token.response.access_token}`.trim();
|
const headerValue = `${headerPrefix} ${token.response[tokenName]}`.trim();
|
||||||
return {
|
return {
|
||||||
setHeaders: [
|
setHeaders: [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user