From ed7a44064f36f8718a8a96294b3542f571ce1486 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 9 Sep 2021 08:34:55 +0200 Subject: [PATCH] [7.x] Expand scope of xpack.security.enabled deprecation warning Show deprecation message not only if "xpack.security.enabled" is false, but just if it's set (no matter the value). Also improves the deprecation message to align with new guidelines. --- .../server/config_deprecations.test.ts | 21 +++++++++++++++++-- .../security/server/config_deprecations.ts | 13 +++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/security/server/config_deprecations.test.ts b/x-pack/plugins/security/server/config_deprecations.test.ts index 08c6d62f48af..3eee6df0d057 100644 --- a/x-pack/plugins/security/server/config_deprecations.test.ts +++ b/x-pack/plugins/security/server/config_deprecations.test.ts @@ -391,12 +391,12 @@ describe('Config Deprecations', () => { expect(migrated).toEqual(config); expect(messages).toMatchInlineSnapshot(` Array [ - "Disabling the security plugin \\"xpack.security.enabled\\" will only be supported by disable security in Elasticsearch.", + "Enabling or disabling the security plugin from Kibana using \\"xpack.security.enabled\\" is deprecated. This should instead be controlled via Elasticsearch.", ] `); }); - it('does not warn when the security plugin is enabled', () => { + it('warns when the security plugin is enabled', () => { const config = { xpack: { security: { @@ -407,6 +407,23 @@ describe('Config Deprecations', () => { }; const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); expect(migrated).toEqual(config); + expect(messages).toMatchInlineSnapshot(` + Array [ + "Enabling or disabling the security plugin from Kibana using \\"xpack.security.enabled\\" is deprecated. This should instead be controlled via Elasticsearch.", + ] + `); + }); + + it("does not warn when xpack.security.enabled isn't set", () => { + const config = { + xpack: { + security: { + session: { idleTimeout: 123, lifespan: 345 }, + }, + }, + }; + const { messages, migrated } = applyConfigDeprecations(cloneDeep(config)); + expect(migrated).toEqual(config); expect(messages).toHaveLength(0); }); }); diff --git a/x-pack/plugins/security/server/config_deprecations.ts b/x-pack/plugins/security/server/config_deprecations.ts index 81b9a90855f5..798edd80c89c 100644 --- a/x-pack/plugins/security/server/config_deprecations.ts +++ b/x-pack/plugins/security/server/config_deprecations.ts @@ -136,22 +136,25 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({ } }, (settings, fromPath, addDeprecation) => { - if (settings?.xpack?.security?.enabled === false) { + if ('enabled' in (settings?.xpack?.security || {})) { addDeprecation({ title: i18n.translate('xpack.security.deprecations.enabledTitle', { - defaultMessage: 'Disabling the security plugin "xpack.security.enabled" is deprecated', + defaultMessage: 'Setting "xpack.security.enabled" is deprecated', }), message: i18n.translate('xpack.security.deprecations.enabledMessage', { defaultMessage: - 'Disabling the security plugin "xpack.security.enabled" will only be supported by disable security in Elasticsearch.', + 'Enabling or disabling the security plugin from Kibana using "xpack.security.enabled" is deprecated. This should instead be controlled via Elasticsearch.', }), + documentationUrl: + 'https://www.elastic.co/guide/en/kibana/current/security-settings-kb.html#general-security-settings', correctiveActions: { manualSteps: [ i18n.translate('xpack.security.deprecations.enabled.manualStepOneMessage', { - defaultMessage: `Remove "xpack.security.enabled" from your Kibana configuration.`, + defaultMessage: 'Remove "xpack.security.enabled" from your Kibana configuration.', }), i18n.translate('xpack.security.deprecations.enabled.manualStepTwoMessage', { - defaultMessage: `To turn off security features, disable them in Elasticsearch instead.`, + defaultMessage: + 'To turn security features on or off, set "xpack.security.enabled" accordingly in Elasticsearch instead.', }), ], },