Skip to content

Commit

Permalink
[Reporting] Add deprecation messages for roles mapped to reporting_us…
Browse files Browse the repository at this point in the history
…er (#115125)

* [Reporting] Add deprecation messages for roles mapped to reporting_user

This fixes the deprecations for various edge cases:
 - when security was disabled, users saw a meaningless error message
 - when users did not have manage_security privilege they saw a meaningless error message

Adds support for checking deprecations related to xpack.reporting.roles.allow

* updates to content per feedback

* updates per feedback

* store packageInfo in reportingCore

* use branch in the documentation links generated in the server

* add tests for scenario where config does not need to be changed
  • Loading branch information
tsullivan authored Oct 20, 2021
1 parent 1cf5089 commit 9231d80
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 138 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/server/config/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('deprecations', () => {
const { messages } = applyReportingDeprecations({ roles: { enabled: true } });
expect(messages).toMatchInlineSnapshot(`
Array [
"Use Kibana application privileges to grant reporting privileges. Using \\"xpack.reporting.roles.allow\\" to grant reporting privileges prevents users from using API Keys to create reports. The \\"xpack.reporting.roles.enabled\\" setting will default to false in a future release.",
"Use Kibana application privileges to grant reporting privileges. Using \\"xpack.reporting.roles.allow\\" to grant reporting privileges is deprecated. The \\"xpack.reporting.roles.enabled\\" setting will default to false in a future release.",
]
`);
});
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/reporting/server/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const config: PluginConfigDescriptor<ReportingConfigType> = {
defaultMessage:
`Use Kibana application privileges to grant reporting privileges.` +
` Using "{fromPath}.roles.allow" to grant reporting privileges` +
` prevents users from using API Keys to create reports.` +
` is deprecated.` +
` The "{fromPath}.roles.enabled" setting will default to false` +
` in a future release.`,
values: { fromPath },
Expand All @@ -74,6 +74,9 @@ export const config: PluginConfigDescriptor<ReportingConfigType> = {
i18n.translate('xpack.reporting.deprecations.reportingRoles.manualStepOne', {
defaultMessage: `Set "xpack.reporting.roles.enabled" to "false" in kibana.yml.`,
}),
i18n.translate('xpack.reporting.deprecations.reportingRoles.manualStepOnePartOne', {
defaultMessage: `Remove "xpack.reporting.roles.allow" to "false" in kibana.yml, if present.`,
}),
i18n.translate('xpack.reporting.deprecations.reportingRoles.manualStepTwo', {
defaultMessage:
`Create one or more roles that grant the Kibana application` +
Expand Down
9 changes: 5 additions & 4 deletions x-pack/plugins/reporting/server/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
BasePath,
IClusterClient,
KibanaRequest,
PackageInfo,
PluginInitializerContext,
SavedObjectsClientContract,
SavedObjectsServiceStart,
Expand Down Expand Up @@ -57,7 +58,7 @@ export interface ReportingInternalStart {
}

export class ReportingCore {
private kibanaVersion: string;
private packageInfo: PackageInfo;
private pluginSetupDeps?: ReportingInternalSetup;
private pluginStartDeps?: ReportingInternalStart;
private readonly pluginSetup$ = new Rx.ReplaySubject<boolean>(); // observe async background setupDeps and config each are done
Expand All @@ -72,7 +73,7 @@ export class ReportingCore {
public getContract: () => ReportingSetup;

constructor(private logger: LevelLogger, context: PluginInitializerContext<ReportingConfigType>) {
this.kibanaVersion = context.env.packageInfo.version;
this.packageInfo = context.env.packageInfo;
const syncConfig = context.config.get<ReportingConfigType>();
this.deprecatedAllowedRoles = syncConfig.roles.enabled ? syncConfig.roles.allow : false;
this.executeTask = new ExecuteReportTask(this, syncConfig, this.logger);
Expand All @@ -85,8 +86,8 @@ export class ReportingCore {
this.executing = new Set();
}

public getKibanaVersion() {
return this.kibanaVersion;
public getKibanaPackageInfo() {
return this.packageInfo;
}

/*
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9231d80

Please sign in to comment.