Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
004dd70
WIP: Move routes to new API, license and other checks inbound
May 8, 2020
938e14a
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 11, 2020
500b933
Move license checks over to np licensing observable
May 12, 2020
b9cc20c
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 12, 2020
4feb02f
Fix license checks + remove older modules
May 14, 2020
02394d5
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 14, 2020
2b18fe2
Fixing check_license tests, move to TS/Jest
May 19, 2020
dfd62f3
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 19, 2020
ac361a8
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 19, 2020
7fab2c6
Fix licensing setup for mocks
May 20, 2020
48c88f8
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 20, 2020
15ece89
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 20, 2020
d58fc14
Move job.test.ts over to np
May 21, 2020
6e1667e
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 21, 2020
007dd57
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 26, 2020
ed1ac8c
WIP: move user checks to higher-order func
May 26, 2020
c08ea7b
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 26, 2020
756551f
Move more handler logic over to Response factory vs Boom
May 26, 2020
7e6efa2
Major refactor to consolidate types, remove facades, and udpate helpers
May 27, 2020
82a1767
Fix validation for dates in immediate exports
May 27, 2020
bb0e7ee
Linter fix on check license test
May 27, 2020
ec94204
Fix job generation tests
May 27, 2020
39a1313
Move deps => setupDeps
May 27, 2020
c7cba25
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 27, 2020
b4e54e1
fix api test
tsullivan May 26, 2020
ee7db9a
fix jobs test
tsullivan May 27, 2020
e7262f4
authorized_user_pre_routing and tests
tsullivan May 27, 2020
d69be5f
Fixing duplicate identifiers
May 28, 2020
107eca0
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 28, 2020
ca58c89
Merge pull request #1 from tsullivan/chore/np-route-migration
joelgriffith May 28, 2020
a8f4bcd
Fix licensing implementation changes
May 28, 2020
54863d0
Merge branch 'chore/np-route-migration' of https://github.com/joelgri…
May 28, 2020
86920d3
WIP: Moving license over to async/observables
May 28, 2020
7532d55
Fix disabled-security case
May 28, 2020
dc57a6f
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 28, 2020
f764bf8
finish auth_user_pre_routing cleanup - no more license check
tsullivan May 28, 2020
01fc733
Merge pull request #2 from tsullivan/chore/np-route-migration
May 28, 2020
874222f
WIP: Fixing final api tests
May 28, 2020
dce4083
Trying to get schema differences in alignment
May 28, 2020
76904b7
Merge branch 'chore/np-route-migration' of https://github.com/joelgri…
May 28, 2020
2a5f9a0
Reverting back to previous generation handler
May 28, 2020
f7d1134
Fix final API tests
May 28, 2020
0aca67c
Final API test fixes, few more hardening tests and better error messages
May 29, 2020
7554127
Merge remote-tracking branch 'upstream/master' into chore/np-route-mi…
May 29, 2020
27040a9
Simplify lower-level module implementation (core only interface) + te…
May 29, 2020
8ad57ff
Push some core logic into plugin
May 29, 2020
4f12c8a
Move some core logic up to plugin
May 29, 2020
3ab8095
Marking private setupDeps + downstream fixes
May 29, 2020
1cf1546
revert logger as a param
tsullivan May 29, 2020
fcf9f58
Merge pull request #3 from tsullivan/chore/np-route-migration
May 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const createJobFactory: CreateJobFactory<ImmediateCreateJobFn<
const {
kibanaSavedObjectMeta: kibanaSavedObjectMetaJSON,
} = attributes as SavedSearchObjectAttributesJSON;
const { timerange } = req.payload as { timerange: TimeRangeParams };
const { timerange } = req.body as { timerange: TimeRangeParams };

if (!kibanaSavedObjectMetaJSON) {
throw new Error('Could not parse saved object data!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { IUiSettingsClient, KibanaRequest } from '../../../../../../../../src/core/server';
import { IUiSettingsClient } from '../../../../../../../../src/core/server';
import {
esQuery,
EsQueryConfig,
Expand All @@ -23,13 +23,7 @@ import {
JobParamsDiscoverCsv,
SearchRequest,
} from '../../../csv/types';
import {
IndexPatternField,
QueryFilter,
SavedSearchObjectAttributes,
SearchPanel,
SearchSource,
} from '../../types';
import { IndexPatternField, QueryFilter, SearchPanel, SearchSource } from '../../types';
import { getDataSource } from './get_data_source';
import { getFilters } from './get_filters';

Expand Down Expand Up @@ -60,11 +54,9 @@ export async function generateCsvSearch(
searchPanel: SearchPanel,
jobParams: JobParamsDiscoverCsv
): Promise<CsvResultFromSearch> {
const savedObjectsClient = await reporting.getSavedObjectsClient(
KibanaRequest.from(req.getRawRequest())
);
const savedObjectsClient = req.getSavedObjectsClient();
const { indexPatternSavedObjectId, timerange } = searchPanel;
const savedSearchObjectAttr = searchPanel.attributes as SavedSearchObjectAttributes;
const savedSearchObjectAttr = searchPanel.attributes;
const { indexPatternSavedObject } = await getDataSource(
savedObjectsClient,
indexPatternSavedObjectId
Expand Down Expand Up @@ -153,9 +145,7 @@ export async function generateCsvSearch(

const config = reporting.getConfig();
const elasticsearch = await reporting.getElasticsearchService();
const { callAsCurrentUser } = elasticsearch.dataClient.asScoped(
KibanaRequest.from(req.getRawRequest())
);
const { callAsCurrentUser } = elasticsearch.dataClient.asScoped(req.getRawRequest());
const callCluster = (...params: [string, object]) => callAsCurrentUser(...params);
const uiSettings = await getUiSettings(uiConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ export function getJobParamsFromRequest(
request: RequestFacade,
opts: { isImmediate: boolean }
): JobParamsPanelCsv {
const { savedObjectType, savedObjectId } = request.params;
const { timerange, state } = request.payload as JobParamsPostPayloadPanelCsv;
const { savedObjectType, savedObjectId } = request.params as {
savedObjectType: string;
savedObjectId: string;
};
const { timerange, state } = request.body as JobParamsPostPayloadPanelCsv;
const post = timerange || state ? { timerange, state } : undefined;

return {
Expand Down
45 changes: 24 additions & 21 deletions x-pack/legacy/plugins/reporting/server/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ import { first, mapTo } from 'rxjs/operators';
import {
ElasticsearchServiceSetup,
KibanaRequest,
SavedObjectsClient,
SavedObjectsServiceStart,
UiSettingsServiceStart,
IRouter,
IBasePath,
SavedObjectsClientContract,
} from 'src/core/server';
import { ReportingPluginSpecOptions } from '../';
// @ts-ignore no module definition
import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status';
import { ILicense } from '../../../../plugins/licensing/server';
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
import { PLUGIN_ID } from '../common/constants';
import { screenshotsObservableFactory } from '../export_types/common/lib/screenshots';
import { ServerFacade } from '../server/types';
import { ServerFacade, ScreenshotsObservableFn } from '../server/types';
import { ReportingConfig } from './';
import { HeadlessChromiumDriverFactory } from './browsers/chromium/driver_factory';
import { checkLicenseFactory, getExportTypesRegistry, LevelLogger } from './lib';
import { checkLicense, getExportTypesRegistry, LevelLogger } from './lib';
import { ESQueueInstance } from './lib/create_queue';
import { EnqueueJobFn } from './lib/enqueue_job';
import { registerRoutes } from './routes';
Expand All @@ -31,7 +33,9 @@ import { ReportingSetupDeps } from './types';
interface ReportingInternalSetup {
browserDriverFactory: HeadlessChromiumDriverFactory;
elasticsearch: ElasticsearchServiceSetup;
license$: Rx.Observable<ILicense>;
}

interface ReportingInternalStart {
enqueueJob: EnqueueJobFn;
esqueue: ESQueueInstance;
Expand All @@ -40,7 +44,8 @@ interface ReportingInternalStart {
}

export class ReportingCore {
private pluginSetupDeps?: ReportingInternalSetup;
pluginSetupDeps?: ReportingInternalSetup;
private license?: ILicense;
private pluginStartDeps?: ReportingInternalStart;
private readonly pluginSetup$ = new Rx.ReplaySubject<ReportingInternalSetup>();
private readonly pluginStart$ = new Rx.ReplaySubject<ReportingInternalStart>();
Expand All @@ -51,26 +56,19 @@ export class ReportingCore {
legacySetup(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

xpackMainPlugin: XPackMainPlugin,
reporting: ReportingPluginSpecOptions,
__LEGACY: ServerFacade,
plugins: ReportingSetupDeps
__LEGACY: ServerFacade
) {
// legacy plugin status
mirrorPluginStatus(xpackMainPlugin, reporting);
}

// legacy license check
const checkLicense = checkLicenseFactory(this.exportTypesRegistry);
(xpackMainPlugin as any).status.once('green', () => {
// Register a function that is called whenever the xpack info changes,
// to re-compute the license check results for this plugin
xpackMainPlugin.info.feature(PLUGIN_ID).registerLicenseCheckResultsGenerator(checkLicense);
});

// legacy routes
registerRoutes(this, __LEGACY, plugins, this.logger);
public setupRoutes(plugins: ReportingSetupDeps, router: IRouter, basePath: IBasePath['get']) {
registerRoutes(this, plugins, router, basePath, this.logger);
}

public pluginSetup(reportingSetupDeps: ReportingInternalSetup) {
this.pluginSetup$.next(reportingSetupDeps);
reportingSetupDeps.license$.subscribe(license => (this.license = license));
}

public pluginStart(reportingStartDeps: ReportingInternalStart) {
Expand All @@ -96,10 +94,15 @@ export class ReportingCore {
return (await this.getPluginStartDeps()).enqueueJob;
}

public getConfig() {
public getLicenseInfo() {
return checkLicense(this.getExportTypesRegistry(), this.license);
}

public getConfig(): ReportingConfig {
return this.config;
}
public async getScreenshotsObservable() {

public async getScreenshotsObservable(): Promise<ScreenshotsObservableFn> {
const { browserDriverFactory } = await this.getPluginSetupDeps();
return screenshotsObservableFactory(this.config.get('capture'), browserDriverFactory);
}
Expand Down Expand Up @@ -127,10 +130,10 @@ export class ReportingCore {

public async getSavedObjectsClient(fakeRequest: KibanaRequest) {
const { savedObjects } = await this.getPluginStartDeps();
return savedObjects.getScopedClient(fakeRequest) as SavedObjectsClient;
return savedObjects.getScopedClient(fakeRequest) as SavedObjectsClientContract;
}

public async getUiSettingsServiceFactory(savedObjectsClient: SavedObjectsClient) {
public async getUiSettingsServiceFactory(savedObjectsClient: SavedObjectsClientContract) {
const { uiSettings: uiSettingsService } = await this.getPluginStartDeps();
const scopedUiSettingsService = uiSettingsService.asScopedToClient(savedObjectsClient);
return scopedUiSettingsService;
Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/reporting/server/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { Legacy } from 'kibana';
import { take } from 'rxjs/operators';
import { PluginInitializerContext } from 'src/core/server';
import { LicensingPluginSetup } from '../../../../plugins/licensing/server';
import { ReportingPluginSpecOptions } from '../';
import { PluginsSetup } from '../../../../plugins/reporting/server';
import { SecurityPluginSetup } from '../../../../plugins/security/server';
Expand Down Expand Up @@ -41,10 +42,12 @@ export const legacyInit = async (
server.newPlatform.coreContext as PluginInitializerContext,
buildConfig(coreSetup, server, reportingConfig)
);

await pluginInstance.setup(coreSetup, {
elasticsearch: coreSetup.elasticsearch,
security: server.newPlatform.setup.plugins.security as SecurityPluginSetup,
usageCollection: server.newPlatform.setup.plugins.usageCollection,
licensing: server.newPlatform.setup.plugins.licensing as LicensingPluginSetup,
__LEGACY,
});

Expand Down
147 changes: 0 additions & 147 deletions x-pack/legacy/plugins/reporting/server/lib/__tests__/check_license.js

This file was deleted.

Loading