-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
921 additions
and
248 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { RecursiveReadonly } from '@kbn/utility-types'; | ||
import { FeatureKibanaPrivileges } from './feature_kibana_privileges'; | ||
import { FeatureElasticsearchPrivileges } from './feature_elasticsearch_privileges'; | ||
|
||
/** | ||
* Interface for registering an Elasticsearch feature. | ||
* Feature registration allows plugins to hide their applications based | ||
* on configured cluster privileges. | ||
*/ | ||
export interface ElasticsearchFeatureConfig { | ||
/** | ||
* Unique identifier for this feature. | ||
* This identifier is also used when generating UI Capabilities. | ||
* | ||
* @see UICapabilities | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Optional array of supported licenses. | ||
* If omitted, all licenses are allowed. | ||
* This does not restrict access to your feature based on license. | ||
* Its only purpose is to inform the space and roles UIs on which features to display. | ||
*/ | ||
validLicenses?: Array<'basic' | 'standard' | 'gold' | 'platinum' | 'enterprise' | 'trial'>; | ||
|
||
/** | ||
* Management sections associated with this feature. | ||
* | ||
* @example | ||
* ```ts | ||
* // Enables access to the "Advanced Settings" management page within the Kibana section | ||
* management: { | ||
* kibana: ['settings'] | ||
* } | ||
* ``` | ||
*/ | ||
management?: { | ||
[sectionId: string]: string[]; | ||
}; | ||
|
||
/** | ||
* If this feature includes a catalogue entry, you can specify them here to control visibility based on the current space. | ||
* | ||
*/ | ||
catalogue?: string[]; | ||
|
||
/** | ||
* Feature privilege definition. | ||
* | ||
* @example | ||
* ```ts | ||
* { | ||
* all: {...}, | ||
* read: {...} | ||
* } | ||
* ``` | ||
* @see FeatureElasticsearchPrivileges | ||
*/ | ||
privileges: { | ||
all: FeatureElasticsearchPrivileges; | ||
read: FeatureElasticsearchPrivileges; | ||
}; | ||
} | ||
|
||
export class ElasticsearchFeature { | ||
constructor(protected readonly config: RecursiveReadonly<ElasticsearchFeatureConfig>) {} | ||
|
||
public get id() { | ||
return this.config.id; | ||
} | ||
|
||
public get catalogue() { | ||
return this.config.catalogue; | ||
} | ||
|
||
public get management() { | ||
return this.config.management; | ||
} | ||
|
||
public get validLicenses() { | ||
return this.config.validLicenses; | ||
} | ||
|
||
public get privileges() { | ||
return this.config.privileges; | ||
} | ||
|
||
public toRaw() { | ||
return { ...this.config } as ElasticsearchFeatureConfig; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/features/common/feature_elasticsearch_privileges.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,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/** | ||
* Elasticsearch Feature privilege definition | ||
*/ | ||
export interface FeatureElasticsearchPrivileges { | ||
requiredClusterPrivileges: string[]; | ||
requiredIndexPrivileges?: { | ||
[indexName: string]: string[]; | ||
}; | ||
|
||
/** | ||
* A list of UI Capabilities that should be granted to users with this privilege. | ||
* These capabilities will automatically be namespaces within your feature id. | ||
* | ||
* @example | ||
* ```ts | ||
* { | ||
* ui: ['show', 'save'] | ||
* } | ||
* | ||
* This translates in the UI to the following (assuming a feature id of "foo"): | ||
* import { uiCapabilities } from 'ui/capabilities'; | ||
* | ||
* const canShowApp = uiCapabilities.foo.show; | ||
* const canSave = uiCapabilities.foo.save; | ||
* ``` | ||
* Note: Since these are automatically namespaced, you are free to use generic names like "show" and "save". | ||
* | ||
* @see UICapabilities | ||
*/ | ||
ui: string[]; | ||
|
||
management?: { | ||
[sectionId: string]: string[]; | ||
}; | ||
} |
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.