From 1ced518ccbb029f955487c31316cd1ddbfe84cfc Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Tue, 11 Dec 2018 07:34:44 -0500 Subject: [PATCH] Initialize authorization mode for reporting jobs (#26762) (#26924) --- .../export_types/common/execute_job/get_custom_logo.ts | 5 +++++ .../plugins/reporting/export_types/csv/server/execute_job.js | 5 +++++ x-pack/plugins/reporting/types.d.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts b/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts index 0b25187a938ae..d20157fc330c0 100644 --- a/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts +++ b/x-pack/plugins/reporting/export_types/common/execute_job/get_custom_logo.ts @@ -25,6 +25,11 @@ export const getCustomLogo = async ({ getBasePath: () => job.basePath || serverBasePath, }; + if (server.plugins.security) { + const { authorization } = server.plugins.security; + await authorization.mode.initialize(fakeRequest); + } + const savedObjects = server.savedObjects; const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(fakeRequest); diff --git a/x-pack/plugins/reporting/export_types/csv/server/execute_job.js b/x-pack/plugins/reporting/export_types/csv/server/execute_job.js index 89ac80016fa55..09a8d6297913d 100644 --- a/x-pack/plugins/reporting/export_types/csv/server/execute_job.js +++ b/x-pack/plugins/reporting/export_types/csv/server/execute_job.js @@ -48,6 +48,11 @@ function executeJobFn(server) { getBasePath: () => basePath || serverBasePath, }; + if (server.plugins.security) { + const { authorization } = server.plugins.security; + await authorization.mode.initialize(fakeRequest); + } + const callEndpoint = (endpoint, clientParams = {}, options = {}) => { return callWithRequest(fakeRequest, endpoint, clientParams, options); }; diff --git a/x-pack/plugins/reporting/types.d.ts b/x-pack/plugins/reporting/types.d.ts index 84d0aad558910..80e534685bb70 100644 --- a/x-pack/plugins/reporting/types.d.ts +++ b/x-pack/plugins/reporting/types.d.ts @@ -14,6 +14,7 @@ type SavedObjectClient = any; export interface KbnServer { info: { protocol: string }; config: () => ConfigObject; + plugins: Record; savedObjects: { getScopedSavedObjectsClient: ( fakeRequest: { headers: object; getBasePath: () => string }