Skip to content

Commit ed7a440

Browse files
committed
[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.
1 parent a3792d6 commit ed7a440

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

x-pack/plugins/security/server/config_deprecations.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,12 @@ describe('Config Deprecations', () => {
391391
expect(migrated).toEqual(config);
392392
expect(messages).toMatchInlineSnapshot(`
393393
Array [
394-
"Disabling the security plugin \\"xpack.security.enabled\\" will only be supported by disable security in Elasticsearch.",
394+
"Enabling or disabling the security plugin from Kibana using \\"xpack.security.enabled\\" is deprecated. This should instead be controlled via Elasticsearch.",
395395
]
396396
`);
397397
});
398398

399-
it('does not warn when the security plugin is enabled', () => {
399+
it('warns when the security plugin is enabled', () => {
400400
const config = {
401401
xpack: {
402402
security: {
@@ -407,6 +407,23 @@ describe('Config Deprecations', () => {
407407
};
408408
const { messages, migrated } = applyConfigDeprecations(cloneDeep(config));
409409
expect(migrated).toEqual(config);
410+
expect(messages).toMatchInlineSnapshot(`
411+
Array [
412+
"Enabling or disabling the security plugin from Kibana using \\"xpack.security.enabled\\" is deprecated. This should instead be controlled via Elasticsearch.",
413+
]
414+
`);
415+
});
416+
417+
it("does not warn when xpack.security.enabled isn't set", () => {
418+
const config = {
419+
xpack: {
420+
security: {
421+
session: { idleTimeout: 123, lifespan: 345 },
422+
},
423+
},
424+
};
425+
const { messages, migrated } = applyConfigDeprecations(cloneDeep(config));
426+
expect(migrated).toEqual(config);
410427
expect(messages).toHaveLength(0);
411428
});
412429
});

x-pack/plugins/security/server/config_deprecations.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,25 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
136136
}
137137
},
138138
(settings, fromPath, addDeprecation) => {
139-
if (settings?.xpack?.security?.enabled === false) {
139+
if ('enabled' in (settings?.xpack?.security || {})) {
140140
addDeprecation({
141141
title: i18n.translate('xpack.security.deprecations.enabledTitle', {
142-
defaultMessage: 'Disabling the security plugin "xpack.security.enabled" is deprecated',
142+
defaultMessage: 'Setting "xpack.security.enabled" is deprecated',
143143
}),
144144
message: i18n.translate('xpack.security.deprecations.enabledMessage', {
145145
defaultMessage:
146-
'Disabling the security plugin "xpack.security.enabled" will only be supported by disable security in Elasticsearch.',
146+
'Enabling or disabling the security plugin from Kibana using "xpack.security.enabled" is deprecated. This should instead be controlled via Elasticsearch.',
147147
}),
148+
documentationUrl:
149+
'https://www.elastic.co/guide/en/kibana/current/security-settings-kb.html#general-security-settings',
148150
correctiveActions: {
149151
manualSteps: [
150152
i18n.translate('xpack.security.deprecations.enabled.manualStepOneMessage', {
151-
defaultMessage: `Remove "xpack.security.enabled" from your Kibana configuration.`,
153+
defaultMessage: 'Remove "xpack.security.enabled" from your Kibana configuration.',
152154
}),
153155
i18n.translate('xpack.security.deprecations.enabled.manualStepTwoMessage', {
154-
defaultMessage: `To turn off security features, disable them in Elasticsearch instead.`,
156+
defaultMessage:
157+
'To turn security features on or off, set "xpack.security.enabled" accordingly in Elasticsearch instead.',
155158
}),
156159
],
157160
},

0 commit comments

Comments
 (0)