Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New platform] HTTP & Security integration #34631

Merged
merged 39 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d827bfb
Add Auth session
mshustov Apr 3, 2019
8b15ce1
add lifecycles
mshustov Apr 3, 2019
7d908de
add types for hapi-auth-cookie
mshustov Apr 3, 2019
218db72
expose interceptors from http service
mshustov Apr 5, 2019
4fbc19c
add integration tests
mshustov Apr 5, 2019
ef83bc1
update tests
mshustov Apr 5, 2019
cb2a5e3
session storage cleanup
mshustov Apr 5, 2019
f417624
get SessionStorage type safe
mshustov Apr 5, 2019
e76bd83
Merge branch 'master' into NP-security-integration
mshustov Apr 9, 2019
2f1dd74
add redirect, clear cookie security integration tests
mshustov Apr 9, 2019
fdc2ff9
add tests for onRequest
mshustov Apr 9, 2019
52a45bd
add tests for onAuth
mshustov Apr 9, 2019
92c08e5
register Auth interceptor only once
mshustov Apr 9, 2019
aa5e08c
refactor redirect tests
mshustov Apr 10, 2019
c70df0f
fix typings, change error message, test suit naming
mshustov Apr 10, 2019
01e6426
add integration test for session validation
mshustov Apr 10, 2019
a9b8c6d
add tests for cookie session storage
mshustov Apr 10, 2019
9f6e8bf
update docs
mshustov Apr 10, 2019
aa2b9ce
Merge branch 'master' into NP-security-integration
mshustov Apr 10, 2019
f747b28
Merge branch 'master' into NP-security-integration
mshustov Apr 10, 2019
d156d30
add integration tests for onRequest
mshustov Apr 10, 2019
87b2b0a
update docs
mshustov Apr 10, 2019
e74bdb7
cleanup onRequest integration tests
mshustov Apr 10, 2019
41cb8bb
Generate docs for AuthToolkit & OnRequestToolkit
mshustov Apr 11, 2019
fadf00b
add test for an exception in interceptor
mshustov Apr 11, 2019
f48e56f
add test OnRequest interceptors dont share request object
mshustov Apr 11, 2019
c043c29
cleanup
mshustov Apr 11, 2019
1c5bd13
address comments from @eli
mshustov Apr 12, 2019
351f8c5
improve typings for onRequest
mshustov Apr 12, 2019
1ce33c7
improve plugin typings
mshustov Apr 12, 2019
85cfd4d
re-generate docs
mshustov Apr 12, 2019
3f500d5
only server defines cookie path
mshustov Apr 12, 2019
cd63747
cookieOptions.password --> cookieOptions.encryptionKey
mshustov Apr 12, 2019
6a93670
CookieOption --> SessionStorageCookieOptions
mshustov Apr 12, 2019
e9e8da0
address comments @joshdover
mshustov Apr 16, 2019
74a8749
Merge branch 'master' into NP-security-integration
mshustov Apr 16, 2019
805b05f
resolve conflict leftovers
mshustov Apr 16, 2019
9e2d026
update @types/hapi-auth-cookie deps
mshustov Apr 16, 2019
4a2656b
update docs
mshustov Apr 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/development/core/server/kibana-plugin-server.authenticate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Home](./index) > [kibana-plugin-server](./kibana-plugin-server.md) > [Authenticate](./kibana-plugin-server.authenticate.md)

## Authenticate type


<b>Signature:</b>

```typescript
export declare type Authenticate<T> = (request: Request, sessionStorage: SessionStorage<T>, t: AuthToolkit) => Promise<AuthResult>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [authenticated](./kibana-plugin-server.authtoolkit.authenticated.md)

## AuthToolkit.authenticated property

Authentication is successful with given credentials, allow request to pass through

<b>Signature:</b>

```typescript
authenticated: (credentials: any) => AuthResult;
```
20 changes: 20 additions & 0 deletions docs/development/core/server/kibana-plugin-server.authtoolkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md)

## AuthToolkit interface

A tool set defining an outcome of Auth interceptor for incoming request.

<b>Signature:</b>

```typescript
export interface AuthToolkit
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [authenticated](./kibana-plugin-server.authtoolkit.authenticated.md) | <code>(credentials: any) =&gt; AuthResult</code> | Authentication is successful with given credentials, allow request to pass through |
| [redirected](./kibana-plugin-server.authtoolkit.redirected.md) | <code>(url: string) =&gt; AuthResult</code> | Authentication requires to interrupt request handling and redirect to a configured url |
| [rejected](./kibana-plugin-server.authtoolkit.rejected.md) | <code>(error: Error, options?: {`<p/>` statusCode?: number;`<p/>` }) =&gt; AuthResult</code> | Authentication is unsuccessful, fail the request with specified error. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [redirected](./kibana-plugin-server.authtoolkit.redirected.md)

## AuthToolkit.redirected property

Authentication requires to interrupt request handling and redirect to a configured url

<b>Signature:</b>

```typescript
redirected: (url: string) => AuthResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [rejected](./kibana-plugin-server.authtoolkit.rejected.md)

## AuthToolkit.rejected property

Authentication is unsuccessful, fail the request with specified error.

<b>Signature:</b>

```typescript
rejected: (error: Error, options?: {
statusCode?: number;
}) => AuthResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md)

## HttpServiceSetup type


<b>Signature:</b>

```typescript
export declare type HttpServiceSetup = HttpServerInfo;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [body](./kibana-plugin-server.kibanarequest.body.md)

## KibanaRequest.body property

<b>Signature:</b>

```typescript
readonly body: Body;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [from](./kibana-plugin-server.kibanarequest.from.md)

## KibanaRequest.from() method

Factory for creating requests. Validates the request before creating an instance of a KibanaRequest.

<b>Signature:</b>

```typescript
static from<P extends ObjectType, Q extends ObjectType, B extends ObjectType>(req: Request, routeSchemas: RouteSchemas<P, Q, B> | undefined): KibanaRequest<P["type"], Q["type"], B["type"]>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| req | <code>Request</code> | |
| routeSchemas | <code>RouteSchemas&lt;P, Q, B&gt; &#124; undefined</code> | |

<b>Returns:</b>

`KibanaRequest<P["type"], Q["type"], B["type"]>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [getFilteredHeaders](./kibana-plugin-server.kibanarequest.getfilteredheaders.md)

## KibanaRequest.getFilteredHeaders() method

<b>Signature:</b>

```typescript
getFilteredHeaders(headersToKeep: string[]): Pick<Record<string, string | string[] | undefined>, string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| headersToKeep | <code>string[]</code> | |

<b>Returns:</b>

`Pick<Record<string, string | string[] | undefined>, string>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [headers](./kibana-plugin-server.kibanarequest.headers.md)

## KibanaRequest.headers property

<b>Signature:</b>

```typescript
readonly headers: Headers;
```
28 changes: 28 additions & 0 deletions docs/development/core/server/kibana-plugin-server.kibanarequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md)

## KibanaRequest class


<b>Signature:</b>

```typescript
export declare class KibanaRequest<Params, Query, Body>
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [body](./kibana-plugin-server.kibanarequest.body.md) | | <code>Body</code> | |
| [headers](./kibana-plugin-server.kibanarequest.headers.md) | | <code>Headers</code> | |
| [params](./kibana-plugin-server.kibanarequest.params.md) | | <code>Params</code> | |
| [path](./kibana-plugin-server.kibanarequest.path.md) | | <code>string</code> | |
| [query](./kibana-plugin-server.kibanarequest.query.md) | | <code>Query</code> | |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [from(req, routeSchemas)](./kibana-plugin-server.kibanarequest.from.md) | <code>static</code> | Factory for creating requests. Validates the request before creating an instance of a KibanaRequest. |
| [getFilteredHeaders(headersToKeep)](./kibana-plugin-server.kibanarequest.getfilteredheaders.md) | | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [params](./kibana-plugin-server.kibanarequest.params.md)

## KibanaRequest.params property

<b>Signature:</b>

```typescript
readonly params: Params;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [path](./kibana-plugin-server.kibanarequest.path.md)

## KibanaRequest.path property

<b>Signature:</b>

```typescript
readonly path: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [query](./kibana-plugin-server.kibanarequest.query.md)

## KibanaRequest.query property

<b>Signature:</b>

```typescript
readonly query: Query;
```
7 changes: 7 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
| --- | --- |
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via <code>asScoped(...)</code>). |
| [ConfigService](./kibana-plugin-server.configservice.md) | |
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | |
| [Router](./kibana-plugin-server.router.md) | |
| [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md) | Serves the same purpose as "normal" <code>ClusterClient</code> but exposes additional <code>callAsCurrentUser</code> method that doesn't use credentials of the Kibana internal user (as <code>callAsInternalUser</code> does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API |

## Interfaces

| Interface | Description |
| --- | --- |
| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
| [CoreSetup](./kibana-plugin-server.coresetup.md) | |
| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of <code>LoggerFactory</code> interface is to define a way to retrieve a context-based logger instance. |
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
| [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) | A tool set defining an outcome of OnRequest interceptor for incoming request. |
| [PluginInitializerContext](./kibana-plugin-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
| [PluginSetupContext](./kibana-plugin-server.pluginsetupcontext.md) | Context passed to the plugins <code>setup</code> method. |

Expand All @@ -28,7 +32,10 @@
| Type Alias | Description |
| --- | --- |
| [APICaller](./kibana-plugin-server.apicaller.md) | |
| [Authenticate](./kibana-plugin-server.authenticate.md) | |
| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
| [Headers](./kibana-plugin-server.headers.md) | |
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | |
| [OnRequest](./kibana-plugin-server.onrequest.md) | |
| [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |

10 changes: 10 additions & 0 deletions docs/development/core/server/kibana-plugin-server.onrequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequest](./kibana-plugin-server.onrequest.md)

## OnRequest type


<b>Signature:</b>

```typescript
export declare type OnRequest<Params = any, Query = any, Body = any> = (req: KibanaRequest<Params, Query, Body>, t: OnRequestToolkit) => OnRequestResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md)

## OnRequestToolkit interface

A tool set defining an outcome of OnRequest interceptor for incoming request.

<b>Signature:</b>

```typescript
export interface OnRequestToolkit
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [next](./kibana-plugin-server.onrequesttoolkit.next.md) | <code>() =&gt; OnRequestResult</code> | To pass request to the next handler |
| [redirected](./kibana-plugin-server.onrequesttoolkit.redirected.md) | <code>(url: string) =&gt; OnRequestResult</code> | To interrupt request handling and redirect to a configured url |
| [rejected](./kibana-plugin-server.onrequesttoolkit.rejected.md) | <code>(error: Error, options?: {`<p/>` statusCode?: number;`<p/>` }) =&gt; OnRequestResult</code> | Fail the request with specified error. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [next](./kibana-plugin-server.onrequesttoolkit.next.md)

## OnRequestToolkit.next property

To pass request to the next handler

<b>Signature:</b>

```typescript
next: () => OnRequestResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [redirected](./kibana-plugin-server.onrequesttoolkit.redirected.md)

## OnRequestToolkit.redirected property

To interrupt request handling and redirect to a configured url

<b>Signature:</b>

```typescript
redirected: (url: string) => OnRequestResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [rejected](./kibana-plugin-server.onrequesttoolkit.rejected.md)

## OnRequestToolkit.rejected property

Fail the request with specified error.

<b>Signature:</b>

```typescript
rejected: (error: Error, options?: {
statusCode?: number;
}) => OnRequestResult;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [PluginSetupContext](./kibana-plugin-server.pluginsetupcontext.md) &gt; [http](./kibana-plugin-server.pluginsetupcontext.http.md)

## PluginSetupContext.http property

<b>Signature:</b>

```typescript
http?: {
registerAuth: HttpServiceSetup['registerAuth'];
registerOnRequest: HttpServiceSetup['registerOnRequest'];
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export interface PluginSetupContext
| Property | Type | Description |
| --- | --- | --- |
| [elasticsearch](./kibana-plugin-server.pluginsetupcontext.elasticsearch.md) | <code>{`<p/>` adminClient$: Observable&lt;ClusterClient&gt;;`<p/>` dataClient$: Observable&lt;ClusterClient&gt;;`<p/>` }</code> | |
| [http](./kibana-plugin-server.pluginsetupcontext.http.md) | <code>{`<p/>` registerAuth: HttpServiceSetup['registerAuth'];`<p/>` registerOnRequest: HttpServiceSetup['registerOnRequest'];`<p/>` }</code> | |

23 changes: 23 additions & 0 deletions docs/development/core/server/kibana-plugin-server.router.delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [delete](./kibana-plugin-server.router.delete.md)

## Router.delete() method

Register a `DELETE` request with the router

<b>Signature:</b>

```typescript
delete<P extends ObjectType, Q extends ObjectType, B extends ObjectType>(route: RouteConfig<P, Q, B>, handler: RequestHandler<P, Q, B>): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| route | <code>RouteConfig&lt;P, Q, B&gt;</code> | |
| handler | <code>RequestHandler&lt;P, Q, B&gt;</code> | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/server/kibana-plugin-server.router.get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [get](./kibana-plugin-server.router.get.md)

## Router.get() method

Register a `GET` request with the router

<b>Signature:</b>

```typescript
get<P extends ObjectType, Q extends ObjectType, B extends ObjectType>(route: RouteConfig<P, Q, B>, handler: RequestHandler<P, Q, B>): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| route | <code>RouteConfig&lt;P, Q, B&gt;</code> | |
| handler | <code>RequestHandler&lt;P, Q, B&gt;</code> | |

<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [getRoutes](./kibana-plugin-server.router.getroutes.md)

## Router.getRoutes() method

Returns all routes registered with the this router.

<b>Signature:</b>

```typescript
getRoutes(): Readonly<RouterRoute>[];
```
<b>Returns:</b>

`Readonly<RouterRoute>[]`

List of registered routes.

Loading