[Security Solution][Endpoint] Require all spaces flag for sub features (#143733)

* Adds requireAllSpaces flag for subfeatures.

* fixes ts errors

* Adds unit test on sub features form UI

* Adds unit test for validateKibanaPrivileges function with subfeatures

* Fixes failing tests

* Rename some vars and reorder return null. Also skip two tests that are not working as expected

* Reorder if condition for performance optimisation

* Fixes unit test

* PR feedback - remove useMemo and use a function

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
David Sánchez 2022-10-26 15:35:45 +02:00 committed by GitHub
parent 0c1ae8c1c2
commit 217d2d0c4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 609 additions and 22 deletions

View file

@ -16,6 +16,17 @@ export interface SubFeatureConfig {
/** Display name for this sub-feature */
name: string;
/**
* Whether or not this privilege should only be granted to `All Spaces *`. Should be used for features that do not
* support Spaces. Defaults to `false`.
*/
requireAllSpaces?: boolean;
/**
* Optional message to display on the Role Management screen when configuring permissions for this feature.
*/
privilegesTooltip?: string;
/** Collection of privilege groups */
privilegeGroups: readonly SubFeaturePrivilegeGroupConfig[];
}
@ -90,6 +101,10 @@ export class SubFeature {
return this.config.privilegeGroups;
}
public get requireAllSpaces() {
return this.config.requireAllSpaces ?? false;
}
public toRaw() {
return { ...this.config };
}