fix(core): Do not add Authentication header when authentication type is body (#8201)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-01-08 12:38:24 +01:00
committed by GitHub
parent ccb2b076f8
commit ac1c642fdd
9 changed files with 117 additions and 94 deletions

View File

@@ -1,4 +1,4 @@
import type { ClientOAuth2Options } from '@n8n/client-oauth2';
import type { ClientOAuth2Options, OAuth2CredentialData } from '@n8n/client-oauth2';
import { ClientOAuth2 } from '@n8n/client-oauth2';
import Csrf from 'csrf';
import { Response } from 'express';
@@ -7,24 +7,11 @@ import * as qs from 'querystring';
import omit from 'lodash/omit';
import set from 'lodash/set';
import split from 'lodash/split';
import type { OAuth2GrantType } from 'n8n-workflow';
import { ApplicationError, jsonParse, jsonStringify } from 'n8n-workflow';
import { Authorized, Get, RestController } from '@/decorators';
import { OAuthRequest } from '@/requests';
import { AbstractOAuthController } from './abstractOAuth.controller';
interface OAuth2CredentialData {
clientId: string;
clientSecret?: string;
accessTokenUrl?: string;
authUrl?: string;
scope?: string;
authQueryParameters?: string;
authentication?: 'header' | 'body';
grantType: OAuth2GrantType;
ignoreSSLIssues?: boolean;
}
interface CsrfStateParam {
cid: string;
token: string;
@@ -226,6 +213,7 @@ export class OAuth2CredentialController extends AbstractOAuthController {
clientSecret: credential.clientSecret ?? '',
accessTokenUri: credential.accessTokenUrl ?? '',
authorizationUri: credential.authUrl ?? '',
authentication: credential.authentication ?? 'header',
redirectUri: `${this.baseUrl}/callback`,
scopes: split(credential.scope ?? 'openid', ','),
scopesSeparator: credential.scope?.includes(',') ? ',' : ' ',