Fix: Canvas socket auth (#24094)

## Summary

Closes https://github.com/elastic/kibana/issues/23303 ~(@cqliu1 can you confirm this too?)~ confirmed

Fixes the way we capture the request info when configuring the socket and providing it to plugins via `callWithRequest`. Instead of exposing a route that returns the info, simply use the request object that comes back from `server.inject`.

Also adds a check in the `elasticsearchClient` handler exposed to plugins to ensure the session is still valid because using `callWithRequest`.

![screenshot 2018-10-16 10 37 56](https://user-images.githubusercontent.com/404731/47036828-32768c00-d132-11e8-81a0-122b5e83c7ef.png)
*Note:* the actual error message is a bit different, but this is how the failure is exposed to the user
This commit is contained in:
Joe Fleming 2018-10-23 17:19:32 -07:00 committed by joe fleming
parent 0522fc7188
commit fe7c9ec9e7
7 changed files with 148 additions and 78 deletions

View file

@ -0,0 +1,17 @@
/*
* 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.
*/
export function getRequest(server, { headers }) {
const basePath = server.config().get('server.basePath') || '/';
return server
.inject({
method: 'GET',
url: basePath,
headers,
})
.then(res => res.request);
}