Skip to content

Commit be280e9

Browse files
Merge branch 'master' into implement/no-cache-cli-flag
2 parents 53536c0 + 1c72279 commit be280e9

279 files changed

Lines changed: 5314 additions & 1376 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"@elastic/eslint-plugin-eui": "0.0.2",
299299
"@elastic/github-checks-reporter": "0.0.20b3",
300300
"@elastic/makelogs": "^5.0.1",
301-
"@elastic/static-fs": "1.0.1",
301+
"@elastic/static-fs": "1.0.2",
302302
"@kbn/dev-utils": "1.0.0",
303303
"@kbn/es": "1.0.0",
304304
"@kbn/eslint-import-resolver-kibana": "2.0.0",

src/core/server/http/cookie_session_storage.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ configService.atPath.mockReturnValue(
6262
disableProtection: true,
6363
whitelist: [],
6464
},
65+
customResponseHeaders: {},
6566
} as any)
6667
);
6768

src/core/server/http/http_config.test.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
*/
1919

2020
import uuid from 'uuid';
21-
import { config } from '.';
21+
import { config, HttpConfig } from './http_config';
22+
import { CspConfig } from '../csp';
2223

2324
const validHostnames = ['www.example.com', '8.8.8.8', '::1', 'localhost'];
2425
const invalidHostname = 'asdf$%^';
@@ -107,6 +108,23 @@ test('throws if xsrf.whitelist element does not start with a slash', () => {
107108
);
108109
});
109110

111+
test('accepts any type of objects for custom headers', () => {
112+
const httpSchema = config.schema;
113+
const obj = {
114+
customResponseHeaders: {
115+
string: 'string',
116+
bool: true,
117+
number: 12,
118+
array: [1, 2, 3],
119+
nested: {
120+
foo: 1,
121+
bar: 'dolly',
122+
},
123+
},
124+
};
125+
expect(() => httpSchema.validate(obj)).not.toThrow();
126+
});
127+
110128
describe('with TLS', () => {
111129
test('throws if TLS is enabled but `redirectHttpFromPort` is equal to `port`', () => {
112130
const httpSchema = config.schema;
@@ -173,3 +191,30 @@ describe('with compression', () => {
173191
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingSnapshot();
174192
});
175193
});
194+
195+
describe('HttpConfig', () => {
196+
it('converts customResponseHeaders to strings or arrays of strings', () => {
197+
const httpSchema = config.schema;
198+
const rawConfig = httpSchema.validate({
199+
customResponseHeaders: {
200+
string: 'string',
201+
bool: true,
202+
number: 12,
203+
array: [1, 2, 3],
204+
nested: {
205+
foo: 1,
206+
bar: 'dolly',
207+
},
208+
},
209+
});
210+
const httpConfig = new HttpConfig(rawConfig, CspConfig.DEFAULT);
211+
212+
expect(httpConfig.customResponseHeaders).toEqual({
213+
string: 'string',
214+
bool: 'true',
215+
number: '12',
216+
array: ['1', '2', '3'],
217+
nested: '{"foo":1,"bar":"dolly"}',
218+
});
219+
});
220+
});

src/core/server/http/http_config.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const config = {
5757
),
5858
schema.boolean({ defaultValue: false })
5959
),
60-
customResponseHeaders: schema.recordOf(schema.string(), schema.string(), {
60+
customResponseHeaders: schema.recordOf(schema.string(), schema.any(), {
6161
defaultValue: {},
6262
}),
6363
host: schema.string({
@@ -136,7 +136,7 @@ export class HttpConfig {
136136
public socketTimeout: number;
137137
public port: number;
138138
public cors: boolean | { origin: string[] };
139-
public customResponseHeaders: Record<string, string>;
139+
public customResponseHeaders: Record<string, string | string[]>;
140140
public maxPayload: ByteSizeValue;
141141
public basePath?: string;
142142
public rewriteBasePath: boolean;
@@ -153,7 +153,15 @@ export class HttpConfig {
153153
this.host = rawHttpConfig.host;
154154
this.port = rawHttpConfig.port;
155155
this.cors = rawHttpConfig.cors;
156-
this.customResponseHeaders = rawHttpConfig.customResponseHeaders;
156+
this.customResponseHeaders = Object.entries(rawHttpConfig.customResponseHeaders ?? {}).reduce(
157+
(headers, [key, value]) => {
158+
return {
159+
...headers,
160+
[key]: Array.isArray(value) ? value.map(e => convertHeader(e)) : convertHeader(value),
161+
};
162+
},
163+
{}
164+
);
157165
this.maxPayload = rawHttpConfig.maxPayload;
158166
this.name = rawHttpConfig.name;
159167
this.basePath = rawHttpConfig.basePath;
@@ -166,3 +174,7 @@ export class HttpConfig {
166174
this.xsrf = rawHttpConfig.xsrf;
167175
}
168176
}
177+
178+
const convertHeader = (entry: any): string => {
179+
return typeof entry === 'object' ? JSON.stringify(entry) : String(entry);
180+
};

src/core/server/http/test_utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ configService.atPath.mockReturnValue(
4545
disableProtection: true,
4646
whitelist: [],
4747
},
48+
customResponseHeaders: {},
4849
} as any)
4950
);
5051

src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { management } from 'ui/management';
21+
import { ManagementSectionId } from '../../../../../../../plugins/management/public';
2122
import './create_index_pattern_wizard';
2223
import './edit_index_pattern';
2324
import uiRoutes from 'ui/routes';
@@ -163,7 +164,7 @@ uiModules
163164
};
164165
});
165166

166-
management.getSection('kibana').register('index_patterns', {
167+
management.getSection(ManagementSectionId.Kibana).register('index_patterns', {
167168
display: i18n.translate('kbn.management.indexPattern.sectionsHeader', {
168169
defaultMessage: 'Index Patterns',
169170
}),

src/plugins/advanced_settings/public/plugin.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
import { i18n } from '@kbn/i18n';
2020
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
21-
import { ManagementApp } from '../../management/public';
21+
import { ManagementApp, ManagementSectionId } from '../../management/public';
2222
import { ComponentRegistry } from './component_registry';
2323
import { AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup } from './types';
2424

@@ -32,15 +32,12 @@ export class AdvancedSettingsPlugin
3232
implements Plugin<AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup> {
3333
private managementApp?: ManagementApp;
3434
public setup(core: CoreSetup, { management }: AdvancedSettingsPluginSetup) {
35-
const kibanaSection = management.sections.getSection('kibana');
36-
if (!kibanaSection) {
37-
throw new Error('`kibana` management section not found.');
38-
}
35+
const kibanaSection = management.sections.getSection(ManagementSectionId.Kibana);
3936

4037
this.managementApp = kibanaSection.registerApp({
4138
id: 'settings',
4239
title,
43-
order: 20,
40+
order: 3,
4441
async mount(params) {
4542
const { mountManagementSection } = await import(
4643
'./management_app/mount_management_section'

src/plugins/data/public/search/long_query_notification.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export function LongQueryNotification(props: Props) {
4444
<EuiButton
4545
size="s"
4646
onClick={async () => {
47-
await props.application.navigateToApp(
48-
'kibana#/management/elasticsearch/license_management'
49-
);
47+
await props.application.navigateToApp('kibana#/management/stack/license_management');
5048
}}
5149
>
5250
<FormattedMessage

src/plugins/management/public/components/management_sidebar_nav/_sidebar_nav.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.mgtSideBarNav {
2-
width: 192px;
2+
width: 210px;
33
}
44

55
@include euiBreakpoint('xs','s') {

src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import {
2525
} from '@elastic/eui';
2626
import { FormattedMessage } from '@kbn/i18n/react';
2727
import { i18n } from '@kbn/i18n';
28-
import React from 'react';
28+
import React, { ReactElement } from 'react';
2929
import { LegacySection, LegacyApp } from '../../types';
3030
import { ManagementApp } from '../../management_app';
3131
import { ManagementSection } from '../../management_section';
3232

3333
interface NavApp {
3434
id: string;
35-
name: string;
35+
name: ReactElement | string;
3636
[key: string]: unknown;
3737
order: number; // only needed while merging platform and legacy
3838
}

0 commit comments

Comments
 (0)