mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Add support for digestAuth to httpRequest and declarative style (#5676)
feat(core): Add support to digestAuth to httpRequest and declarative style
This commit is contained in:
@@ -224,7 +224,7 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||
node: INode,
|
||||
defaultTimezone: string,
|
||||
): string {
|
||||
if (parameterValue.charAt(0) !== '=') {
|
||||
if (typeof parameterValue !== 'string' || parameterValue.charAt(0) !== '=') {
|
||||
return parameterValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -825,15 +825,31 @@ function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequest
|
||||
async function httpRequest(
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IN8nHttpFullResponse | IN8nHttpResponse> {
|
||||
const axiosRequest = convertN8nRequestToAxios(requestOptions);
|
||||
let axiosRequest = convertN8nRequestToAxios(requestOptions);
|
||||
if (
|
||||
axiosRequest.data === undefined ||
|
||||
(axiosRequest.method !== undefined && axiosRequest.method.toUpperCase() === 'GET')
|
||||
) {
|
||||
delete axiosRequest.data;
|
||||
}
|
||||
let result: AxiosResponse<any>;
|
||||
try {
|
||||
result = await axios(axiosRequest);
|
||||
} catch (error) {
|
||||
if (requestOptions.auth?.sendImmediately === false) {
|
||||
const { response } = error;
|
||||
if (response?.status !== 401 || !response.headers['www-authenticate']?.includes('nonce')) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const { auth } = axiosRequest;
|
||||
delete axiosRequest.auth;
|
||||
axiosRequest = digestAuthAxiosConfig(axiosRequest, response, auth);
|
||||
result = await axios(axiosRequest);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const result = await axios(axiosRequest);
|
||||
if (requestOptions.returnFullResponse) {
|
||||
return {
|
||||
body: result.data,
|
||||
@@ -842,6 +858,7 @@ async function httpRequest(
|
||||
statusMessage: result.statusText,
|
||||
};
|
||||
}
|
||||
|
||||
return result.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ export interface IRequestOptionsSimplified {
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
sendImmediately?: boolean;
|
||||
};
|
||||
body: IDataObject;
|
||||
headers: IDataObject;
|
||||
@@ -182,6 +183,7 @@ export interface IRequestOptionsSimplifiedAuth {
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
sendImmediately?: boolean;
|
||||
};
|
||||
body?: IDataObject;
|
||||
headers?: IDataObject;
|
||||
@@ -501,6 +503,7 @@ export interface IHttpRequestOptions {
|
||||
auth?: {
|
||||
username: string;
|
||||
password: string;
|
||||
sendImmediately?: boolean;
|
||||
};
|
||||
disableFollowRedirect?: boolean;
|
||||
encoding?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
|
||||
|
||||
Reference in New Issue
Block a user