Skip to content

Commit

Permalink
Merge branch 'master' into issue_56651
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Feb 4, 2020
2 parents b60bdaa + d73e15f commit 15f9bca
Show file tree
Hide file tree
Showing 121 changed files with 1,515 additions and 478 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,18 @@ module.exports = {
// '@typescript-eslint/unbound-method': 'error',
},
},
// {
// // will introduced after the other warns are fixed
// // typescript and javascript for front end react performance
// files: ['x-pack/legacy/plugins/siem/public/**/!(*.test).{js,ts,tsx}'],
// plugins: ['react-perf'],
// rules: {
// // 'react-perf/jsx-no-new-object-as-prop': 'error',
// // 'react-perf/jsx-no-new-array-as-prop': 'error',
// // 'react-perf/jsx-no-new-function-as-prop': 'error',
// // 'react/jsx-no-bind': 'error',
// },
// },
{
// typescript and javascript for front and back end
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
Expand Down Expand Up @@ -747,8 +759,6 @@ module.exports = {
// will introduced after the other warns are fixed
// 'react/sort-comp': 'error',
'react/void-dom-elements-no-children': 'error',
// will introduced after the other warns are fixed
// 'react/jsx-no-bind': 'error',
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-literals': 'error',
'react/jsx-no-target-blank': 'error',
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app
/src/legacy/core_plugins/metrics/ @elastic/kibana-app
/src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app
/src/legacy/core_plugins/vis_type_xy/ @elastic/kibana-app
# Exclude tutorials folder for now because they are not owned by Kibana app and most will move out soon
/src/plugins/home/public @elastic/kibana-app
/src/plugins/home/server/*.ts @elastic/kibana-app
Expand Down
6 changes: 5 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"interpreter": "src/legacy/core_plugins/interpreter",
"kbn": "src/legacy/core_plugins/kibana",
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
"management": ["src/legacy/core_plugins/management", "src/plugins/management"],
"management": [
"src/legacy/core_plugins/management",
"src/plugins/management"
],
"kibana_react": "src/legacy/core_plugins/kibana_react",
"kibana-react": "src/plugins/kibana_react",
"kibana_utils": "src/plugins/kibana_utils",
Expand All @@ -43,6 +46,7 @@
"visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"],
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visTypeVislib": "src/legacy/core_plugins/vis_type_vislib",
"visTypeXy": "src/legacy/core_plugins/vis_type_xy",
"visualizations": [
"src/plugins/visualizations",
"src/legacy/core_plugins/visualizations"
Expand Down
1 change: 1 addition & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ files:
- 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/vis_type_vislib/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/vis_type_xy/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const provider: ConfigDeprecationProvider = ({ rename, unused }) => [
| Method | Description |
| --- | --- |
| [rename(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.rename.md) | Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. |
| [renameFromRoot(oldKey, newKey)](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.<!-- -->This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. |
| [renameFromRoot(oldKey, newKey, silent)](./kibana-plugin-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.<!-- -->This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. |
| [unused(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unused.md) | Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. |
| [unusedFromRoot(unusedKey)](./kibana-plugin-server.configdeprecationfactory.unusedfromroot.md) | Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied.<!-- -->This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. |

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This should be only used when renaming properties from different configuration's
<b>Signature:</b>

```typescript
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation;
```

## Parameters
Expand All @@ -20,6 +20,7 @@ renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
| --- | --- | --- |
| oldKey | <code>string</code> | |
| newKey | <code>string</code> | |
| silent | <code>boolean</code> | |

<b>Returns:</b>

Expand Down
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md) &gt; [host](./kibana-plugin-server.httpserverinfo.host.md)

## HttpServerInfo.host property

The hostname of the server

<b>Signature:</b>

```typescript
host: string;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md)

## HttpServerInfo interface


<b>Signature:</b>

```typescript
export interface HttpServerInfo
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [host](./kibana-plugin-server.httpserverinfo.host.md) | <code>string</code> | The hostname of the server |
| [name](./kibana-plugin-server.httpserverinfo.name.md) | <code>string</code> | The name of the Kibana server |
| [port](./kibana-plugin-server.httpserverinfo.port.md) | <code>number</code> | The port the server is listening on |
| [protocol](./kibana-plugin-server.httpserverinfo.protocol.md) | <code>'http' &#124; 'https' &#124; 'socket'</code> | The protocol used by the server |

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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md) &gt; [name](./kibana-plugin-server.httpserverinfo.name.md)

## HttpServerInfo.name property

The name of the Kibana server

<b>Signature:</b>

```typescript
name: string;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md) &gt; [port](./kibana-plugin-server.httpserverinfo.port.md)

## HttpServerInfo.port property

The port the server is listening on

<b>Signature:</b>

```typescript
port: number;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md) &gt; [protocol](./kibana-plugin-server.httpserverinfo.protocol.md)

## HttpServerInfo.protocol property

The protocol used by the server

<b>Signature:</b>

```typescript
protocol: 'http' | 'https' | 'socket';
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) &gt; [getServerInfo](./kibana-plugin-server.httpservicesetup.getserverinfo.md)

## HttpServiceSetup.getServerInfo property

Provides common [information](./kibana-plugin-server.httpserverinfo.md) about the running http server.

<b>Signature:</b>

```typescript
getServerInfo: () => HttpServerInfo;
```
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async (context, request, response) => {
| [createCookieSessionStorageFactory](./kibana-plugin-server.httpservicesetup.createcookiesessionstoragefactory.md) | <code>&lt;T&gt;(cookieOptions: SessionStorageCookieOptions&lt;T&gt;) =&gt; Promise&lt;SessionStorageFactory&lt;T&gt;&gt;</code> | Creates cookie based session storage factory [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) |
| [createRouter](./kibana-plugin-server.httpservicesetup.createrouter.md) | <code>() =&gt; IRouter</code> | Provides ability to declare a handler function for a particular path and HTTP request method. |
| [csp](./kibana-plugin-server.httpservicesetup.csp.md) | <code>ICspConfig</code> | The CSP config used for Kibana. |
| [getServerInfo](./kibana-plugin-server.httpservicesetup.getserverinfo.md) | <code>() =&gt; HttpServerInfo</code> | Provides common [information](./kibana-plugin-server.httpserverinfo.md) about the running http server. |
| [isTlsEnabled](./kibana-plugin-server.httpservicesetup.istlsenabled.md) | <code>boolean</code> | Flag showing whether a server was configured to use TLS connection. |
| [registerAuth](./kibana-plugin-server.httpservicesetup.registerauth.md) | <code>(handler: AuthenticationHandler) =&gt; void</code> | To define custom authentication and/or authorization mechanism for incoming requests. |
| [registerOnPostAuth](./kibana-plugin-server.httpservicesetup.registeronpostauth.md) | <code>(handler: OnPostAuthHandler) =&gt; void</code> | To define custom logic to perform for incoming requests. |
Expand Down
1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
| [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters |
| [HttpServerInfo](./kibana-plugin-server.httpserverinfo.md) | |
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to <code>hapi</code> server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
| [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. |
Expand Down
6 changes: 6 additions & 0 deletions docs/migration/migrate_8_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ specified explicitly.

*Impact:* Define `xpack.security.authc.saml.realm` when using the SAML authentication provider instead.

[float]
==== `/api/security/v1/saml` endpoint is no longer supported
*Details:* The deprecated `/api/security/v1/saml` endpoint is no longer supported.

*Impact:* Rely on `/api/security/saml/callback` endpoint when using SAML instead. This change should be reflected in Kibana `server.xsrf.whitelist` config as well as in Elasticsearch and Identity Provider SAML settings.

[float]
=== `optimize` directory is now in the `data` folder
*Details:* Generated bundles have moved to the configured `path.data` folder.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-plugin-react-perf": "^3.2.3",
"exit-hook": "^2.2.0",
"faker": "1.1.0",
"fetch-mock": "^7.3.9",
Expand Down
20 changes: 13 additions & 7 deletions src/core/server/config/deprecation/deprecation_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const _rename = (
rootPath: string,
log: ConfigDeprecationLogger,
oldKey: string,
newKey: string
newKey: string,
silent?: boolean
) => {
const fullOldPath = getPath(rootPath, oldKey);
const oldValue = get(config, fullOldPath);
Expand All @@ -40,11 +41,16 @@ const _rename = (
const newValue = get(config, fullNewPath);
if (newValue === undefined) {
set(config, fullNewPath, oldValue);
log(`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}"`);

if (!silent) {
log(`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}"`);
}
} else {
log(
`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}". However both key are present, ignoring "${fullOldPath}"`
);
if (!silent) {
log(
`"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}". However both key are present, ignoring "${fullOldPath}"`
);
}
}
return config;
};
Expand All @@ -67,11 +73,11 @@ const _unused = (
const rename = (oldKey: string, newKey: string): ConfigDeprecation => (config, rootPath, log) =>
_rename(config, rootPath, log, oldKey, newKey);

const renameFromRoot = (oldKey: string, newKey: string): ConfigDeprecation => (
const renameFromRoot = (oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation => (
config,
rootPath,
log
) => _rename(config, '', log, oldKey, newKey);
) => _rename(config, '', log, oldKey, newKey, silent);

const unused = (unusedKey: string): ConfigDeprecation => (config, rootPath, log) =>
_unused(config, rootPath, log, unusedKey);
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/deprecation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export interface ConfigDeprecationFactory {
* ]
* ```
*/
renameFromRoot(oldKey: string, newKey: string): ConfigDeprecation;
renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation;
/**
* Remove a configuration property from inside a plugin's configuration path.
* Will log a deprecation warning if the unused key was found and deprecation applied.
Expand Down
34 changes: 34 additions & 0 deletions src/core/server/http/http_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ beforeAll(() => {

beforeEach(() => {
config = {
name: 'kibana',
host: '127.0.0.1',
maxPayload: new ByteSizeValue(1024),
port: 10002,
Expand Down Expand Up @@ -1077,4 +1078,37 @@ describe('setup contract', () => {
expect(isTlsEnabled).toBe(false);
});
});

describe('#getServerInfo', () => {
it('returns correct information', async () => {
let { getServerInfo } = await server.setup(config);

expect(getServerInfo()).toEqual({
host: '127.0.0.1',
name: 'kibana',
port: 10002,
protocol: 'http',
});

({ getServerInfo } = await server.setup({
...config,
port: 12345,
name: 'custom-name',
host: 'localhost',
}));

expect(getServerInfo()).toEqual({
host: 'localhost',
name: 'custom-name',
port: 12345,
protocol: 'http',
});
});

it('returns correct protocol when ssl is enabled', async () => {
const { getServerInfo } = await server.setup(configWithSSL);

expect(getServerInfo().protocol).toEqual('https');
});
});
});
9 changes: 8 additions & 1 deletion src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
import { IsAuthenticated, AuthStateStorage, GetAuthState } from './auth_state_storage';
import { AuthHeadersStorage, GetAuthHeaders } from './auth_headers_storage';
import { BasePath } from './base_path_service';
import { HttpServiceSetup } from './types';
import { HttpServiceSetup, HttpServerInfo } from './types';

/** @internal */
export interface HttpServerSetup {
Expand All @@ -58,6 +58,7 @@ export interface HttpServerSetup {
get: GetAuthState;
isAuthenticated: IsAuthenticated;
};
getServerInfo: () => HttpServerInfo;
}

/** @internal */
Expand Down Expand Up @@ -122,6 +123,12 @@ export class HttpServer {
isAuthenticated: this.authState.isAuthenticated,
},
getAuthHeaders: this.authRequestHeaders.get,
getServerInfo: () => ({
name: config.name,
host: config.host,
port: config.port,
protocol: this.server!.info.protocol,
}),
isTlsEnabled: config.ssl.enabled,
// Return server instance with the connection options so that we can properly
// bridge core and the "legacy" Kibana internally. Once this bridge isn't
Expand Down
7 changes: 7 additions & 0 deletions src/core/server/http/http_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ const createSetupContractMock = () => {
auth: createAuthMock(),
getAuthHeaders: jest.fn(),
isTlsEnabled: false,
getServerInfo: jest.fn(),
};
setupContract.createCookieSessionStorageFactory.mockResolvedValue(
sessionStorageMock.createFactory()
);
setupContract.createRouter.mockImplementation(() => mockRouter.create());
setupContract.getAuthHeaders.mockReturnValue({ authorization: 'authorization-header' });
setupContract.getServerInfo.mockReturnValue({
host: 'localhost',
name: 'kibana',
port: 80,
protocol: 'http',
});
return setupContract;
};

Expand Down
17 changes: 17 additions & 0 deletions src/core/server/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ export interface HttpServiceSetup {
contextName: T,
provider: RequestHandlerContextProvider<T>
) => RequestHandlerContextContainer;

/**
* Provides common {@link HttpServerInfo | information} about the running http server.
*/
getServerInfo: () => HttpServerInfo;
}

/** @internal */
Expand All @@ -273,3 +278,15 @@ export interface HttpServiceStart {
/** Indicates if http server is listening on a given port */
isListening: (port: number) => boolean;
}

/** @public */
export interface HttpServerInfo {
/** The name of the Kibana server */
name: string;
/** The hostname of the server */
host: string;
/** The port the server is listening on */
port: number;
/** The protocol used by the server */
protocol: 'http' | 'https' | 'socket';
}
Loading

0 comments on commit 15f9bca

Please sign in to comment.