Skip to content

Commit f118f83

Browse files
committed
Prevent Spaces from being disabled
* Change config * Remove related deprecations * Remove space-disabled elements from role management UI * Remove security_only functional tests
1 parent 3e6516c commit f118f83

File tree

86 files changed

+360
-7675
lines changed

Some content is hidden

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

86 files changed

+360
-7675
lines changed

docs/settings/spaces-settings.asciidoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
By default, spaces is enabled in {kib}. To secure spaces, <<security-settings-kb,enable security>>.
99

10-
`xpack.spaces.enabled`::
11-
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported and it will not be possible to disable this plugin."]
12-
To enable spaces, set to `true`.
13-
The default is `true`.
14-
1510
`xpack.spaces.maxSpaces`::
1611
The maximum number of spaces that you can use with the {kib} instance. Some {kib} operations
1712
return all spaces using a single `_search` from {es}, so you must

src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ kibana_vars=(
382382
xpack.securitySolution.packagerTaskInterval
383383
xpack.securitySolution.prebuiltRulesFromFileSystem
384384
xpack.securitySolution.prebuiltRulesFromSavedObjects
385-
xpack.spaces.enabled
386385
xpack.spaces.maxSpaces
387386
xpack.task_manager.index
388387
xpack.task_manager.max_attempts

x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx

Lines changed: 1 addition & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { userAPIClientMock } from '../../users/index.mock';
2222
import { createRawKibanaPrivileges } from '../__fixtures__/kibana_privileges';
2323
import { indicesAPIClientMock, privilegesAPIClientMock, rolesAPIClientMock } from '../index.mock';
2424
import { EditRolePage } from './edit_role_page';
25-
import { SimplePrivilegeSection } from './privileges/kibana/simple_privilege_section';
2625
import { SpaceAwarePrivilegeSection } from './privileges/kibana/space_aware_privilege_section';
2726
import { TransformErrorSection } from './privileges/kibana/transform_error_section';
2827

@@ -132,12 +131,10 @@ function getProps({
132131
action,
133132
role,
134133
canManageSpaces = true,
135-
spacesEnabled = true,
136134
}: {
137135
action: 'edit' | 'clone';
138136
role?: Role;
139137
canManageSpaces?: boolean;
140-
spacesEnabled?: boolean;
141138
}) {
142139
const rolesAPIClient = rolesAPIClientMock.create();
143140
rolesAPIClient.getRole.mockResolvedValue(role);
@@ -165,12 +162,7 @@ function getProps({
165162
const { http, docLinks, notifications } = coreMock.createStart();
166163
http.get.mockImplementation(async (path: any) => {
167164
if (path === '/api/spaces/space') {
168-
if (spacesEnabled) {
169-
return buildSpaces();
170-
}
171-
172-
const notFoundError = { response: { status: 404 } };
173-
throw notFoundError;
165+
return buildSpaces();
174166
}
175167
});
176168

@@ -335,152 +327,6 @@ describe('<EditRolePage />', () => {
335327
});
336328
});
337329

338-
describe('with spaces disabled', () => {
339-
it('can render a reserved role', async () => {
340-
const wrapper = mountWithIntl(
341-
<EditRolePage
342-
{...getProps({
343-
action: 'edit',
344-
spacesEnabled: false,
345-
role: {
346-
name: 'superuser',
347-
metadata: { _reserved: true },
348-
elasticsearch: { cluster: ['all'], indices: [], run_as: ['*'] },
349-
kibana: [{ spaces: ['*'], base: ['all'], feature: {} }],
350-
},
351-
})}
352-
/>
353-
);
354-
355-
await waitForRender(wrapper);
356-
357-
expect(wrapper.find('[data-test-subj="reservedRoleBadgeTooltip"]')).toHaveLength(1);
358-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
359-
expect(wrapper.find('[data-test-subj="userCannotManageSpacesCallout"]')).toHaveLength(0);
360-
expectReadOnlyFormButtons(wrapper);
361-
});
362-
363-
it('can render a user defined role', async () => {
364-
const wrapper = mountWithIntl(
365-
<EditRolePage
366-
{...getProps({
367-
action: 'edit',
368-
spacesEnabled: false,
369-
role: {
370-
name: 'my custom role',
371-
metadata: {},
372-
elasticsearch: { cluster: ['all'], indices: [], run_as: ['*'] },
373-
kibana: [{ spaces: ['*'], base: ['all'], feature: {} }],
374-
},
375-
})}
376-
/>
377-
);
378-
379-
await waitForRender(wrapper);
380-
381-
expect(wrapper.find('[data-test-subj="reservedRoleBadgeTooltip"]')).toHaveLength(0);
382-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
383-
expect(wrapper.find('[data-test-subj="userCannotManageSpacesCallout"]')).toHaveLength(0);
384-
expectSaveFormButtons(wrapper);
385-
});
386-
387-
it('can render when creating a new role', async () => {
388-
const wrapper = mountWithIntl(
389-
<EditRolePage {...getProps({ action: 'edit', spacesEnabled: false })} />
390-
);
391-
392-
await waitForRender(wrapper);
393-
394-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
395-
expectSaveFormButtons(wrapper);
396-
});
397-
398-
it('can render when cloning an existing role', async () => {
399-
const wrapper = mountWithIntl(
400-
<EditRolePage
401-
{...getProps({
402-
action: 'edit',
403-
spacesEnabled: false,
404-
role: {
405-
metadata: { _reserved: false },
406-
name: '',
407-
elasticsearch: {
408-
cluster: ['all', 'manage'],
409-
indices: [
410-
{
411-
names: ['foo*'],
412-
privileges: ['all'],
413-
field_security: { except: ['f'], grant: ['b*'] },
414-
},
415-
],
416-
run_as: ['elastic'],
417-
},
418-
kibana: [{ spaces: ['*'], base: ['all'], feature: {} }],
419-
},
420-
})}
421-
/>
422-
);
423-
424-
await waitForRender(wrapper);
425-
426-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
427-
expectSaveFormButtons(wrapper);
428-
});
429-
430-
it('does not care if user cannot manage spaces', async () => {
431-
const wrapper = mountWithIntl(
432-
<EditRolePage
433-
{...getProps({
434-
action: 'edit',
435-
spacesEnabled: false,
436-
canManageSpaces: false,
437-
role: {
438-
name: 'my custom role',
439-
metadata: {},
440-
elasticsearch: { cluster: ['all'], indices: [], run_as: ['*'] },
441-
kibana: [{ spaces: ['*'], base: ['all'], feature: {} }],
442-
},
443-
})}
444-
/>
445-
);
446-
447-
await waitForRender(wrapper);
448-
449-
expect(wrapper.find('[data-test-subj="reservedRoleBadgeTooltip"]')).toHaveLength(0);
450-
451-
expect(
452-
wrapper.find('EuiCallOut[data-test-subj="userCannotManageSpacesCallout"]')
453-
).toHaveLength(0);
454-
455-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
456-
expectSaveFormButtons(wrapper);
457-
});
458-
459-
it('renders a partial read-only view when there is a transform error', async () => {
460-
const wrapper = mountWithIntl(
461-
<EditRolePage
462-
{...getProps({
463-
action: 'edit',
464-
spacesEnabled: false,
465-
canManageSpaces: false,
466-
role: {
467-
name: 'my custom role',
468-
metadata: {},
469-
elasticsearch: { cluster: ['all'], indices: [], run_as: ['*'] },
470-
kibana: [],
471-
_transform_error: ['kibana'],
472-
},
473-
})}
474-
/>
475-
);
476-
477-
await waitForRender(wrapper);
478-
479-
expect(wrapper.find(TransformErrorSection)).toHaveLength(1);
480-
expectReadOnlyFormButtons(wrapper);
481-
});
482-
});
483-
484330
it('registers fatal error if features endpoint fails unexpectedly', async () => {
485331
const error = { response: { status: 500 } };
486332
const getFeatures = jest.fn().mockRejectedValue(error);

x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ export const EditRolePage: FunctionComponent<Props> = ({
436436
<KibanaPrivilegesRegion
437437
kibanaPrivileges={new KibanaPrivileges(kibanaPrivileges, features)}
438438
spaces={spaces.list}
439-
spacesEnabled={spaces.enabled}
440439
uiCapabilities={uiCapabilities}
441440
canCustomizeSubFeaturePrivileges={license.getFeatures().allowSubFeaturePrivileges}
442441
editable={!isRoleReadOnly}
@@ -521,7 +520,7 @@ export const EditRolePage: FunctionComponent<Props> = ({
521520
setFormError(null);
522521

523522
try {
524-
await rolesAPIClient.saveRole({ role, spacesEnabled: spaces.enabled });
523+
await rolesAPIClient.saveRole({ role });
525524
} catch (error) {
526525
notifications.toasts.addDanger(
527526
error?.body?.message ??
@@ -566,24 +565,17 @@ export const EditRolePage: FunctionComponent<Props> = ({
566565
backToRoleList();
567566
};
568567

569-
const description = spaces.enabled ? (
570-
<FormattedMessage
571-
id="xpack.security.management.editRole.setPrivilegesToKibanaSpacesDescription"
572-
defaultMessage="Set privileges on your Elasticsearch data and control access to your Kibana spaces."
573-
/>
574-
) : (
575-
<FormattedMessage
576-
id="xpack.security.management.editRole.setPrivilegesToKibanaDescription"
577-
defaultMessage="Set privileges on your Elasticsearch data and control access to Kibana."
578-
/>
579-
);
580-
581568
return (
582569
<div className="editRolePage">
583570
<EuiForm {...formError}>
584571
{getFormTitle()}
585572
<EuiSpacer />
586-
<EuiText size="s">{description}</EuiText>
573+
<EuiText size="s">
574+
<FormattedMessage
575+
id="xpack.security.management.editRole.setPrivilegesToKibanaSpacesDescription"
576+
defaultMessage="Set privileges on your Elasticsearch data and control access to your Kibana spaces."
577+
/>
578+
</EuiText>
587579
{isRoleReserved && (
588580
<Fragment>
589581
<EuiSpacer size="s" />

x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.test.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import type { Role } from '../../../../../../common/model';
1212
import { KibanaPrivileges } from '../../../model';
1313
import { RoleValidator } from '../../validate_role';
1414
import { KibanaPrivilegesRegion } from './kibana_privileges_region';
15-
import { SimplePrivilegeSection } from './simple_privilege_section';
1615
import { SpaceAwarePrivilegeSection } from './space_aware_privilege_section';
1716
import { TransformErrorSection } from './transform_error_section';
1817

19-
const buildProps = (customProps = {}) => {
18+
const buildProps = () => {
2019
return {
2120
role: {
2221
name: '',
@@ -27,7 +26,6 @@ const buildProps = (customProps = {}) => {
2726
},
2827
kibana: [],
2928
},
30-
spacesEnabled: true,
3129
spaces: [
3230
{
3331
id: 'default',
@@ -64,7 +62,6 @@ const buildProps = (customProps = {}) => {
6462
onChange: jest.fn(),
6563
validator: new RoleValidator(),
6664
canCustomizeSubFeaturePrivileges: true,
67-
...customProps,
6865
};
6966
};
7067

@@ -73,26 +70,17 @@ describe('<KibanaPrivileges>', () => {
7370
expect(shallow(<KibanaPrivilegesRegion {...buildProps()} />)).toMatchSnapshot();
7471
});
7572

76-
it('renders the simple privilege form when spaces is disabled', () => {
77-
const props = buildProps({ spacesEnabled: false });
73+
it('renders the space-aware privilege form', () => {
74+
const props = buildProps();
7875
const wrapper = shallow(<KibanaPrivilegesRegion {...props} />);
79-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(1);
80-
expect(wrapper.find(SpaceAwarePrivilegeSection)).toHaveLength(0);
81-
});
82-
83-
it('renders the space-aware privilege form when spaces is enabled', () => {
84-
const props = buildProps({ spacesEnabled: true });
85-
const wrapper = shallow(<KibanaPrivilegesRegion {...props} />);
86-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(0);
8776
expect(wrapper.find(SpaceAwarePrivilegeSection)).toHaveLength(1);
8877
});
8978

9079
it('renders the transform error section when the role has a transform error', () => {
91-
const props = buildProps({ spacesEnabled: true });
80+
const props = buildProps();
9281
(props.role as Role)._transform_error = ['kibana'];
9382

9483
const wrapper = shallow(<KibanaPrivilegesRegion {...props} />);
95-
expect(wrapper.find(SimplePrivilegeSection)).toHaveLength(0);
9684
expect(wrapper.find(SpaceAwarePrivilegeSection)).toHaveLength(0);
9785
expect(wrapper.find(TransformErrorSection)).toHaveLength(1);
9886
});

x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/kibana_privileges_region.tsx

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import type { Role } from '../../../../../../common/model';
1414
import type { KibanaPrivileges } from '../../../model';
1515
import { CollapsiblePanel } from '../../collapsible_panel';
1616
import type { RoleValidator } from '../../validate_role';
17-
import { SimplePrivilegeSection } from './simple_privilege_section';
1817
import { SpaceAwarePrivilegeSection } from './space_aware_privilege_section';
1918
import { TransformErrorSection } from './transform_error_section';
2019

2120
interface Props {
2221
role: Role;
23-
spacesEnabled: boolean;
2422
canCustomizeSubFeaturePrivileges: boolean;
2523
spaces?: Space[];
2624
uiCapabilities: Capabilities;
@@ -44,7 +42,6 @@ export class KibanaPrivilegesRegion extends Component<Props, {}> {
4442
const {
4543
kibanaPrivileges,
4644
role,
47-
spacesEnabled,
4845
canCustomizeSubFeaturePrivileges,
4946
spaces = [],
5047
uiCapabilities,
@@ -58,30 +55,18 @@ export class KibanaPrivilegesRegion extends Component<Props, {}> {
5855
return <TransformErrorSection />;
5956
}
6057

61-
if (spacesEnabled) {
62-
return (
63-
<SpaceAwarePrivilegeSection
64-
kibanaPrivileges={kibanaPrivileges}
65-
role={role}
66-
spaces={spaces}
67-
uiCapabilities={uiCapabilities}
68-
onChange={onChange}
69-
editable={editable}
70-
canCustomizeSubFeaturePrivileges={canCustomizeSubFeaturePrivileges}
71-
validator={validator}
72-
spacesApiUi={spacesApiUi!}
73-
/>
74-
);
75-
} else {
76-
return (
77-
<SimplePrivilegeSection
78-
kibanaPrivileges={kibanaPrivileges}
79-
role={role}
80-
onChange={onChange}
81-
editable={editable}
82-
canCustomizeSubFeaturePrivileges={canCustomizeSubFeaturePrivileges}
83-
/>
84-
);
85-
}
58+
return (
59+
<SpaceAwarePrivilegeSection
60+
kibanaPrivileges={kibanaPrivileges}
61+
role={role}
62+
spaces={spaces}
63+
uiCapabilities={uiCapabilities}
64+
onChange={onChange}
65+
editable={editable}
66+
canCustomizeSubFeaturePrivileges={canCustomizeSubFeaturePrivileges}
67+
validator={validator}
68+
spacesApiUi={spacesApiUi!}
69+
/>
70+
);
8671
};
8772
}

0 commit comments

Comments
 (0)