forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Static config settings for serverless (elastic#16…
…7856) ## Summary This PR implements a standard way to have different static settings for the serverless and ess (stateful) environments. It centralizes flags, which were set using different approaches previously, in a single configuration. This aims to make it easier for developers to enable/disable parts of the application in serverless projects. Default: ``` sideNavEnabled: true, ILMEnabled: true, ESQLEnabled: true, ``` Serverless: ``` xpack.securitySolution.offeringSettings: { sideNavEnabled: false, # Internal security side navigation disabled, the serverless global chrome navigation is used instead ILMEnabled: false, # Index Lifecycle Management (ILM) functionalities disabled, not supported by serverless Elasticsearch ESQLEnabled: false, # ES|QL disabled, not supported by serverless Elasticsearch } ``` ### Consume the settings #### Server - Plugin parsed `ConfigType`: `this.config.settings.ESQLEnabled` #### UI - Plugin attribute: `this.configSettings.ESQLEnabled`. - Components can access it from Kibana services: `useKibana().services.configSettings.ESQLEnabled;` --------- Co-authored-by: Vitalii Dmyterko <[email protected]>
- Loading branch information
Showing
25 changed files
with
161 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/security_solution/common/config_settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface ConfigSettings { | ||
/** | ||
* Security solution internal side navigation enabled | ||
*/ | ||
sideNavEnabled: boolean; | ||
/** | ||
* Index Lifecycle Management (ILM) feature enabled. | ||
*/ | ||
ILMEnabled: boolean; | ||
/** | ||
* ESQL queries enabled. | ||
*/ | ||
ESQLEnabled: boolean; | ||
} | ||
|
||
/** | ||
* A list of allowed values that can be override in `xpack.securitySolution.offeringSettings`. | ||
* This object is then used to validate and parse the value entered. | ||
*/ | ||
export const defaultSettings: ConfigSettings = Object.freeze({ | ||
sideNavEnabled: true, | ||
ILMEnabled: true, | ||
ESQLEnabled: true, | ||
}); | ||
|
||
type ConfigSettingsKey = keyof ConfigSettings; | ||
|
||
/** | ||
* Parses the string value used in `xpack.securitySolution.offeringSettings` kibana configuration, | ||
* | ||
* @param offeringSettings | ||
*/ | ||
export const parseConfigSettings = ( | ||
offeringSettings: Record<string, boolean> | ||
): { settings: ConfigSettings; invalid: string[] } => { | ||
const configSettings: Partial<ConfigSettings> = {}; | ||
const invalidKeys: string[] = []; | ||
|
||
for (const optionKey in offeringSettings) { | ||
if (defaultSettings[optionKey as ConfigSettingsKey] == null) { | ||
invalidKeys.push(optionKey); | ||
} else { | ||
configSettings[optionKey as ConfigSettingsKey] = offeringSettings[optionKey]; | ||
} | ||
} | ||
|
||
const settings: ConfigSettings = Object.freeze({ | ||
...defaultSettings, | ||
...configSettings, | ||
}); | ||
|
||
return { | ||
settings, | ||
invalid: invalidKeys, | ||
}; | ||
}; | ||
|
||
export const getDefaultConfigSettings = (): ConfigSettings => ({ ...defaultSettings }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.