-
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.
Migrate Capabilities to new platform (#51438)
* create service skeleton * move registerCapabilitiesModifier to capabilities service and rename to registerCapabilitiesSwitcher * starts to move capabilities logic to CapabilitiesService * move capabilities route to service * add initial integration test for capabilities route * capabilitiesMixin now delegates to capability service * use server-side Capabilities import in server code * update generated doc * remove capabilities from injectedMetadatas * use applications sent from client instead of server-registered navLinks * disable authRequired for capabilities route * (temp) exposes two endpoints for capabilities * Add fetch-mock on capabilities call for karma tests * adapt xpack Capabilities test - first attempt * adapt x-pack ui_capabilities test * add '/status' to the list of anonymous pages * Add documentation on Capabilities APIs * move Capabilities to core/types * update generated docs * add service tests * protecting resolveCapabilities against added/removed capabilities * update generated docs * adapt mocks due to rebase * add forgotten exports * improve capabilities routes registering * name capabilities registering methods * resolve conflicts due to merge * address review issues * add comment about reason for exposing two routes * extract createHttpServer test helper * fix merge conflicts * improve documentation * remove `/status` anon registration as now done in NP status plugin * fix merge conflicts
- Loading branch information
1 parent
609a7f5
commit 99c6396
Showing
79 changed files
with
3,357 additions
and
2,423 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
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.capabilities.catalogue.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Capabilities](./kibana-plugin-server.capabilities.md) > [catalogue](./kibana-plugin-server.capabilities.catalogue.md) | ||
|
||
## Capabilities.catalogue property | ||
|
||
Catalogue capabilities. Catalogue entries drive the visibility of the Kibana homepage options. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
catalogue: Record<string, boolean>; | ||
``` |
15 changes: 15 additions & 0 deletions
15
docs/development/core/server/kibana-plugin-server.capabilities.management.md
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,15 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Capabilities](./kibana-plugin-server.capabilities.md) > [management](./kibana-plugin-server.capabilities.management.md) | ||
|
||
## Capabilities.management property | ||
|
||
Management section capabilities. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
management: { | ||
[sectionId: string]: Record<string, boolean>; | ||
}; | ||
``` |
22 changes: 22 additions & 0 deletions
22
docs/development/core/server/kibana-plugin-server.capabilities.md
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,22 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Capabilities](./kibana-plugin-server.capabilities.md) | ||
|
||
## Capabilities interface | ||
|
||
The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface Capabilities | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [catalogue](./kibana-plugin-server.capabilities.catalogue.md) | <code>Record<string, boolean></code> | Catalogue capabilities. Catalogue entries drive the visibility of the Kibana homepage options. | | ||
| [management](./kibana-plugin-server.capabilities.management.md) | <code>{</code><br/><code> [sectionId: string]: Record<string, boolean>;</code><br/><code> }</code> | Management section capabilities. | | ||
| [navLinks](./kibana-plugin-server.capabilities.navlinks.md) | <code>Record<string, boolean></code> | Navigation link capabilities. | | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.capabilities.navlinks.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [Capabilities](./kibana-plugin-server.capabilities.md) > [navLinks](./kibana-plugin-server.capabilities.navlinks.md) | ||
|
||
## Capabilities.navLinks property | ||
|
||
Navigation link capabilities. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
navLinks: Record<string, boolean>; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.capabilitiesprovider.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) | ||
|
||
## CapabilitiesProvider type | ||
|
||
See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type CapabilitiesProvider = () => Partial<Capabilities>; | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs/development/core/server/kibana-plugin-server.capabilitiessetup.md
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,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | ||
|
||
## CapabilitiesSetup interface | ||
|
||
APIs to manage the [Capabilities](./kibana-plugin-server.capabilities.md) that will be used by the application. | ||
|
||
Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the `registerProvider` method. | ||
|
||
Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the `registerSwitcher` method. | ||
|
||
Refers to the methods documentation for complete description and examples. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface CapabilitiesSetup | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [registerProvider(provider)](./kibana-plugin-server.capabilitiessetup.registerprovider.md) | Register a [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) to be used to provide [Capabilities](./kibana-plugin-server.capabilities.md) when resolving them. | | ||
| [registerSwitcher(switcher)](./kibana-plugin-server.capabilitiessetup.registerswitcher.md) | Register a [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) to be used to change the default state of the [Capabilities](./kibana-plugin-server.capabilities.md) entries when resolving them.<!-- -->A capabilities switcher can only change the state of existing capabilities. Capabilities added or removed when invoking the switcher will be ignored. | | ||
|
46 changes: 46 additions & 0 deletions
46
...elopment/core/server/kibana-plugin-server.capabilitiessetup.registerprovider.md
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,46 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) > [registerProvider](./kibana-plugin-server.capabilitiessetup.registerprovider.md) | ||
|
||
## CapabilitiesSetup.registerProvider() method | ||
|
||
Register a [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) to be used to provide [Capabilities](./kibana-plugin-server.capabilities.md) when resolving them. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
registerProvider(provider: CapabilitiesProvider): void; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| provider | <code>CapabilitiesProvider</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`void` | ||
|
||
## Example | ||
|
||
How to register a plugin's capabilities during setup | ||
|
||
```ts | ||
// my-plugin/server/plugin.ts | ||
public setup(core: CoreSetup, deps: {}) { | ||
core.capabilities.registerProvider(() => { | ||
return { | ||
catalogue: { | ||
myPlugin: true, | ||
}, | ||
myPlugin: { | ||
someFeature: true, | ||
featureDisabledByDefault: false, | ||
}, | ||
} | ||
}); | ||
} | ||
|
||
``` | ||
|
47 changes: 47 additions & 0 deletions
47
...elopment/core/server/kibana-plugin-server.capabilitiessetup.registerswitcher.md
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,47 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) > [registerSwitcher](./kibana-plugin-server.capabilitiessetup.registerswitcher.md) | ||
|
||
## CapabilitiesSetup.registerSwitcher() method | ||
|
||
Register a [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) to be used to change the default state of the [Capabilities](./kibana-plugin-server.capabilities.md) entries when resolving them. | ||
|
||
A capabilities switcher can only change the state of existing capabilities. Capabilities added or removed when invoking the switcher will be ignored. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
registerSwitcher(switcher: CapabilitiesSwitcher): void; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| switcher | <code>CapabilitiesSwitcher</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`void` | ||
|
||
## Example | ||
|
||
How to restrict some capabilities | ||
|
||
```ts | ||
// my-plugin/server/plugin.ts | ||
public setup(core: CoreSetup, deps: {}) { | ||
core.capabilities.registerSwitcher((request, capabilities) => { | ||
if(myPluginApi.shouldRestrictSomePluginBecauseOf(request)) { | ||
return { | ||
somePlugin: { | ||
featureEnabledByDefault: false // `featureEnabledByDefault` will be disabled. All other capabilities will remain unchanged. | ||
} | ||
} | ||
} | ||
return {}; // All capabilities will remain unchanged. | ||
}); | ||
} | ||
|
||
``` | ||
|
20 changes: 20 additions & 0 deletions
20
docs/development/core/server/kibana-plugin-server.capabilitiesstart.md
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,20 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | ||
|
||
## CapabilitiesStart interface | ||
|
||
APIs to access the application [Capabilities](./kibana-plugin-server.capabilities.md)<!-- -->. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface CapabilitiesStart | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [resolveCapabilities(request)](./kibana-plugin-server.capabilitiesstart.resolvecapabilities.md) | Resolve the [Capabilities](./kibana-plugin-server.capabilities.md) to be used for given request | | ||
|
24 changes: 24 additions & 0 deletions
24
...pment/core/server/kibana-plugin-server.capabilitiesstart.resolvecapabilities.md
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,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) > [resolveCapabilities](./kibana-plugin-server.capabilitiesstart.resolvecapabilities.md) | ||
|
||
## CapabilitiesStart.resolveCapabilities() method | ||
|
||
Resolve the [Capabilities](./kibana-plugin-server.capabilities.md) to be used for given request | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
resolveCapabilities(request: KibanaRequest): Promise<Capabilities>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| request | <code>KibanaRequest</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`Promise<Capabilities>` | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.capabilitiesswitcher.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) | ||
|
||
## CapabilitiesSwitcher type | ||
|
||
See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type CapabilitiesSwitcher = (request: KibanaRequest, uiCapabilities: Capabilities) => Partial<Capabilities> | Promise<Partial<Capabilities>>; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.coresetup.capabilities.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CoreSetup](./kibana-plugin-server.coresetup.md) > [capabilities](./kibana-plugin-server.coresetup.capabilities.md) | ||
|
||
## CoreSetup.capabilities property | ||
|
||
[CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
capabilities: CapabilitiesSetup; | ||
``` |
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
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.corestart.capabilities.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CoreStart](./kibana-plugin-server.corestart.md) > [capabilities](./kibana-plugin-server.corestart.capabilities.md) | ||
|
||
## CoreStart.capabilities property | ||
|
||
[CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
capabilities: CapabilitiesStart; | ||
``` |
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
Oops, something went wrong.