diff --git a/kibana-reports/server/routes/lib/createReport.ts b/kibana-reports/server/routes/lib/createReport.ts index b194165c..7d3106ff 100644 --- a/kibana-reports/server/routes/lib/createReport.ts +++ b/kibana-reports/server/routes/lib/createReport.ts @@ -30,7 +30,7 @@ import { createSavedSearchReport } from '../utils/savedSearchReportHelper'; import { ReportSchemaType } from '../../model'; import { CreateReportResultType } from '../utils/types'; import { createVisualReport } from '../utils/visual_report/visualReportHelper'; -import { SetCookie } from 'puppeteer-core'; +import { SetCookie, Headers } from 'puppeteer-core'; import { deliverReport } from './deliverReport'; import { updateReportState } from './updateReportState'; import { saveReport } from './saveReport'; @@ -114,6 +114,16 @@ export const createReport = async ( } }); } + // If header exists assuming that it needs forwarding + let additionalHeaders: Headers | undefined; + if (request.headers[SECURITY_CONSTANTS.PROXY_AUTH_USER_HEADER]) { + additionalHeaders = {} + additionalHeaders[SECURITY_CONSTANTS.PROXY_AUTH_USER_HEADER] = request.headers[SECURITY_CONSTANTS.PROXY_AUTH_USER_HEADER]; + additionalHeaders[SECURITY_CONSTANTS.PROXY_AUTH_IP_HEADER] = request.headers[SECURITY_CONSTANTS.PROXY_AUTH_IP_HEADER]; + if (request.headers[SECURITY_CONSTANTS.PROXY_AUTH_ROLES_HEADER]) { + additionalHeaders[SECURITY_CONSTANTS.PROXY_AUTH_ROLES_HEADER] = request.headers[SECURITY_CONSTANTS.PROXY_AUTH_ROLES_HEADER] + } + } const [value, release] = await semaphore.acquire(); try { createReportResult = await createVisualReport( @@ -121,6 +131,7 @@ export const createReport = async ( completeQueryUrl, logger, cookieObject, + additionalHeaders, timezone ); } finally { diff --git a/kibana-reports/server/routes/utils/constants.ts b/kibana-reports/server/routes/utils/constants.ts index 1df80057..79f1ec5b 100644 --- a/kibana-reports/server/routes/utils/constants.ts +++ b/kibana-reports/server/routes/utils/constants.ts @@ -78,6 +78,9 @@ export const DEFAULT_REPORT_HEADER = '