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

[Spaces] - Space aware privileges UI #21049

Merged
merged 100 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f208d3c
Crude and incomplete impl of Space-Aware Saved Objects Client
legrego May 7, 2018
7538bf3
Code review updates
legrego May 8, 2018
bb3e511
Missed one - move extraBodyProperties to the top
legrego May 8, 2018
0e2e4e8
Remove documentFilter from bulkGet
legrego May 9, 2018
a6287cc
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego May 21, 2018
7db0a4a
Make config document id independent of Kibana version
legrego May 21, 2018
de0adb6
partial impl
legrego Jun 18, 2018
192d9c2
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jun 18, 2018
1c4afd8
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jun 20, 2018
d573457
cleanup and fixes following initial rbac phase 1 merge
legrego Jun 20, 2018
d99cec7
remove unused/migrated files
legrego Jun 20, 2018
7e2d1e3
remove unused code
legrego Jun 20, 2018
862752b
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jun 20, 2018
a63128c
partial updates for space aware saved objects and tests
legrego Jun 22, 2018
858eff0
working get & find functional tests
legrego Jun 22, 2018
1b95aa0
added bulk_get tests
legrego Jun 22, 2018
fc663d9
refactor query params into dedicated module
legrego Jun 25, 2018
fc61594
additional tests and bugfixes for space aware saved objects
legrego Jun 25, 2018
776da8a
revert changes to ui settings service
legrego Jun 25, 2018
d2545d4
additional tests for space-aware saved objects
legrego Jun 25, 2018
1fd7699
Fix navigating to the default space
legrego Jun 25, 2018
9469742
additional unit tests
legrego Jun 25, 2018
e24578f
Create default space on startup, *after* ES has gone green
legrego Jun 25, 2018
5fe4bfd
support & testing for bulk_create for space-enabled installations
legrego Jun 26, 2018
c6e8925
cleanup and docs
legrego Jun 26, 2018
1bc36c7
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jun 26, 2018
0544eb3
Merge branch 'space-aware-saved-objects' into space-aware-privileges
legrego Jun 26, 2018
b878051
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jun 26, 2018
f4a19ab
undo formatting changes
legrego Jun 27, 2018
46e7c71
update for rxjs6 compat
legrego Jun 27, 2018
3220623
experimental WIP for space change callbacks
legrego Jun 27, 2018
392c7ea
start to refactor kibana privileges form
legrego Jun 28, 2018
dee335b
only allow filters to be passed to getQueryParams
legrego Jun 29, 2018
452de10
don't add space id when updating within the default space
legrego Jun 29, 2018
6bf3515
renaming files
legrego Jun 29, 2018
8cb871a
additional SOC and repository tests
legrego Jul 5, 2018
53bb020
remove default context from utility functions
legrego Jul 5, 2018
90892ca
rename spacesSavedObjectsClientWrapper => spacesSavedObjectsClientWra…
legrego Jul 5, 2018
4181c9e
don't mutate passed options for SOC create method
legrego Jul 5, 2018
a35d15f
allow options to be passed for get and bulkGet
legrego Jul 5, 2018
093dd47
additional review updates
legrego Jul 5, 2018
6e1c4c4
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jul 5, 2018
2195ee0
consolidate init logic
legrego Jul 5, 2018
48c5f23
Add error handling when switching spaces
legrego Jul 6, 2018
3a832e9
rename single character variables
legrego Jul 6, 2018
71f0634
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jul 9, 2018
ca0b4d0
Merge branch 'space-aware-saved-objects' into space-aware-privileges
legrego Jul 9, 2018
a4c1ddb
additional WIP changes
legrego Jul 9, 2018
00bd94c
fix merge
legrego Jul 16, 2018
415fa09
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jul 16, 2018
8d48c80
Merge branch 'spaces-phase-1' into space-aware-saved-objects
legrego Jul 19, 2018
edd1089
update role screen to use new public roles api
legrego Jul 20, 2018
1a65ca9
Merge branch 'spaces-phase-1' into update-roles-screen-spaces
legrego Jul 20, 2018
95ef05c
update spaces and role management to conform to new user management s…
legrego Jul 20, 2018
2461a12
Merge branch 'space-aware-saved-objects' into space-aware-privileges
legrego Jul 20, 2018
79ca48e
Merge branch 'update-roles-screen-spaces' into space-aware-privileges
legrego Jul 20, 2018
aaa3ebf
space aware privileges using public roles api
legrego Jul 20, 2018
ca4883f
reorganize ES privilege components
legrego Jul 20, 2018
841f9a8
improve prop naming
legrego Jul 20, 2018
4e96943
additional tests
legrego Jul 20, 2018
f2e39c1
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jul 20, 2018
1527858
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jul 23, 2018
b9ed305
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jul 26, 2018
0ce04ef
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Jul 27, 2018
5d462e0
improve styling of space selector control
legrego Jul 27, 2018
46d1d22
fix spacing around privilege forms
legrego Jul 27, 2018
08d9096
cleanup and additional testing
legrego Jul 30, 2018
112d992
Design edits (#8)
cchaos Jul 31, 2018
9d0b173
fix tests following design edits
legrego Jul 31, 2018
372e206
Delete index.css
legrego Aug 1, 2018
b8f4269
show impacted spaces when base privilege is set to all
legrego Aug 15, 2018
42ba27f
Merge branch 'space-aware-privileges' of github.com:legrego/kibana in…
legrego Aug 15, 2018
ab43322
fix action column
legrego Aug 15, 2018
71d5119
show impacted spaces regardless of the minimum permission
legrego Aug 15, 2018
51d83a4
adjust sizing and alignment; bugfix for flyout privileges
legrego Aug 15, 2018
5297bc3
adjust alignment and responsiveness of flex group
legrego Aug 15, 2018
b4cbc26
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Aug 15, 2018
a22a638
fix react warning
legrego Aug 15, 2018
482c1e9
show empty index form when role does not include any index privileges
legrego Aug 15, 2018
ce635ee
change ES cluster privileges to use a combobox instead of a checkbox …
legrego Aug 15, 2018
c325845
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Aug 16, 2018
c9f5824
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Aug 17, 2018
99376f8
update role management page to use new role api
legrego Aug 17, 2018
8780832
move shared components
legrego Aug 17, 2018
d00c5e5
cleanup
legrego Aug 17, 2018
dd28bd7
use common 'manage spaces' button
legrego Aug 17, 2018
344cceb
fix broken import reference
legrego Aug 17, 2018
3beaeb8
update security tests to work with updated role management form
legrego Aug 20, 2018
ade287d
fix snapshot tests
legrego Aug 21, 2018
febbdf5
remove kibana privilege view model
legrego Aug 21, 2018
cc1e357
let => const
legrego Aug 21, 2018
cba659f
fix displayed space permission when minimum privilege > assigned spac…
legrego Aug 21, 2018
aff7d89
reserved state of roles not reflected by screen reader. Fixes #20192
legrego Aug 21, 2018
c7b5069
Allow Kibana privileges to be managed if the Spaces plugin is disabled
legrego Aug 21, 2018
c8d3045
additional testing and bugfixes
legrego Aug 21, 2018
631463c
add validation to kibana privileges
legrego Aug 21, 2018
a3be801
show deleted spaces in the privilege list
legrego Aug 21, 2018
681792d
Merge branch 'spaces-phase-1' into space-aware-privileges
legrego Aug 24, 2018
812652d
fix reference
legrego Aug 24, 2018
eea0eb8
TypeScript-ify role management
legrego Aug 24, 2018
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
2 changes: 1 addition & 1 deletion x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = function (kibana) {
graph(kibana),
monitoring(kibana),
reporting(kibana),
spaces(kibana),
security(kibana),
searchprofiler(kibana),
ml(kibana),
Expand All @@ -44,7 +45,6 @@ module.exports = function (kibana) {
cloud(kibana),
indexManagement(kibana),
consoleExtensions(kibana),
spaces(kibana),
notifications(kibana),
kueryAutocomplete(kibana)
];
Expand Down
14 changes: 14 additions & 0 deletions x-pack/plugins/security/common/model/index_privilege.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 interface IndexPrivilege {
names: string[];
privileges: string[];
field_security?: {
grant?: string[];
};
query?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export class Role {
name = null;
cluster = [];
indices = [];
run_as = []; //eslint-disable-line camelcase
applications = [];
import { KibanaPrivilege } from './kibana_privilege';

export interface KibanaApplicationPrivilege {
name: KibanaPrivilege;
}
7 changes: 7 additions & 0 deletions x-pack/plugins/security/common/model/kibana_privilege.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* 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 type KibanaPrivilege = 'none' | 'read' | 'all';
29 changes: 29 additions & 0 deletions x-pack/plugins/security/common/model/role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.
*/

import { IndexPrivilege } from './index_privilege';
import { KibanaPrivilege } from './kibana_privilege';

export interface Role {
name: string;
elasticsearch: {
cluster: string[];
indices: IndexPrivilege[];
run_as: string[];
};
kibana: {
global: KibanaPrivilege[];
space: {
[spaceId: string]: KibanaPrivilege[];
};
};
metadata?: {
[anyKey: string]: any;
};
transient_metadata?: {
[anyKey: string]: any;
};
}
1 change: 1 addition & 0 deletions x-pack/plugins/security/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const security = (kibana) => new kibana.Plugin({
return {
secureCookies: config.get('xpack.security.secureCookies'),
sessionTimeout: config.get('xpack.security.sessionTimeout'),
enableSpaceAwarePrivileges: config.get('xpack.spaces.enabled'),
};
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { isRoleEnabled, isReservedRole } from './role';
import { isReservedRole, isRoleEnabled } from './role';

describe('role', () => {
describe('isRoleEnabled', () => {
test('should return false if role is explicitly not enabled', () => {
const testRole = {
transient_metadata: {
enabled: false
}
enabled: false,
},
};
expect(isRoleEnabled(testRole)).toBe(false);
});

test('should return true if role is explicitly enabled', () => {
const testRole = {
transient_metadata: {
enabled: true
}
enabled: true,
},
};
expect(isRoleEnabled(testRole)).toBe(true);
});
Expand All @@ -36,17 +36,17 @@ describe('role', () => {
test('should return false if role is explicitly not reserved', () => {
const testRole = {
metadata: {
_reserved: false
}
_reserved: false,
},
};
expect(isReservedRole(testRole)).toBe(false);
});

test('should return true if role is explicitly reserved', () => {
const testRole = {
metadata: {
_reserved: true
}
_reserved: true,
},
};
expect(isReservedRole(testRole)).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*/

import { get } from 'lodash';
import { Role } from '../../common/model/role';

/**
* Returns whether given role is enabled or not
*
* @param role Object Role JSON, as returned by roles API
* @return Boolean true if role is enabled; false otherwise
*/
export function isRoleEnabled(role) {
export function isRoleEnabled(role: Partial<Role>) {
return get(role, 'transient_metadata.enabled', true);
}

Expand All @@ -21,6 +22,6 @@ export function isRoleEnabled(role) {
*
* @param {role} the Role as returned by roles API
*/
export function isReservedRole(role) {
export function isReservedRole(role: Partial<Role>) {
return get(role, 'metadata._reserved', false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { IHttpResponse } from 'angular';
import chrome from 'ui/chrome';

const apiBase = chrome.addBasePath(`/api/security/v1/fields`);

export async function getFields($http, query) {
export async function getFields($http: any, query: string): Promise<string[]> {
return await $http
.get(`${apiBase}/${query}`)
.then(response => response.data || []);
.then((response: IHttpResponse<string[]>) => response.data || []);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import chrome from 'ui/chrome';
import { omit } from 'lodash';
import chrome from 'ui/chrome';
import { Role } from '../../../common/model/role';

const apiBase = chrome.addBasePath(`/api/security/role`);

export async function saveRole($http, role) {
export async function saveRole($http: any, role: Role) {
const data = omit(role, 'name', 'transient_metadata', '_unrecognized_applications');
return await $http.put(`${apiBase}/${role.name}`, data);
}

export async function deleteRole($http, name) {
export async function deleteRole($http: any, name: string) {
return await $http.delete(`${apiBase}/${name}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ exports[`it renders without blowing up 1`] = `
<EuiLink
color="primary"
onClick={[Function]}
size="s"
type="button"
>
hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiLink } from '@elastic/eui';
import { mount, shallow } from 'enzyme';
import React from 'react';
import { shallow, mount } from 'enzyme';
import { CollapsiblePanel } from './collapsible_panel';
import { EuiLink } from '@elastic/eui';

test('it renders without blowing up', () => {
const wrapper = shallow(
<CollapsiblePanel
iconType="logoElasticsearch"
title="Elasticsearch"
>
<CollapsiblePanel iconType="logoElasticsearch" title="Elasticsearch">
<p>child</p>
</CollapsiblePanel>
);
Expand All @@ -24,10 +21,7 @@ test('it renders without blowing up', () => {

test('it renders children by default', () => {
const wrapper = mount(
<CollapsiblePanel
iconType="logoElasticsearch"
title="Elasticsearch"
>
<CollapsiblePanel iconType="logoElasticsearch" title="Elasticsearch">
<p className="child">child 1</p>
<p className="child">child 2</p>
</CollapsiblePanel>
Expand All @@ -39,10 +33,7 @@ test('it renders children by default', () => {

test('it hides children when the "hide" link is clicked', () => {
const wrapper = mount(
<CollapsiblePanel
iconType="logoElasticsearch"
title="Elasticsearch"
>
<CollapsiblePanel iconType="logoElasticsearch" title="Elasticsearch">
<p className="child">child 1</p>
<p className="child">child 2</p>
</CollapsiblePanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,33 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import './collapsible_panel.less';
import {
EuiPanel,
EuiLink,
EuiIcon,
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiIcon,
EuiLink,
EuiPanel,
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import React, { Component, Fragment } from 'react';
import './collapsible_panel.less';

export class CollapsiblePanel extends Component {
static propTypes = {
iconType: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
}
interface Props {
iconType: string | any;
title: string;
}

state = {
collapsed: false
}
interface State {
collapsed: boolean;
}

render() {
export class CollapsiblePanel extends Component<Props, State> {
public state = {
collapsed: false,
};

public render() {
return (
<EuiPanel>
{this.getTitle()}
Expand All @@ -36,24 +39,30 @@ export class CollapsiblePanel extends Component {
);
}

getTitle = () => {
public getTitle = () => {
return (
// @ts-ignore
<EuiFlexGroup alignItems={'baseline'} gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>
<EuiTitle>
<h2>
<EuiIcon type={this.props.iconType} size={'xl'} className={'collapsiblePanel__logo'} /> {this.props.title}
<EuiIcon
type={this.props.iconType}
size={'xl'}
className={'collapsiblePanel__logo'}
/>{' '}
{this.props.title}
</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink size={'s'} onClick={this.toggleCollapsed}>{this.state.collapsed ? 'show' : 'hide'}</EuiLink>
<EuiLink onClick={this.toggleCollapsed}>{this.state.collapsed ? 'show' : 'hide'}</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
);
};

getForm = () => {
public getForm = () => {
if (this.state.collapsed) {
return null;
}
Expand All @@ -64,11 +73,11 @@ export class CollapsiblePanel extends Component {
{this.props.children}
</Fragment>
);
}
};

toggleCollapsed = () => {
public toggleCollapsed = () => {
this.setState({
collapsed: !this.state.collapsed
collapsed: !this.state.collapsed,
});
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import {
EuiButton,
EuiButtonEmpty,
// @ts-ignore
EuiConfirmModal,
} from '@elastic/eui';
import { mount, shallow } from 'enzyme';
import React from 'react';
import { DeleteRoleButton } from './delete_role_button';
import {
shallow,
mount
} from 'enzyme';

test('it renders without crashing', () => {
const deleteHandler = jest.fn();
const wrapper = shallow(<DeleteRoleButton canDelete={true} onDelete={deleteHandler} />);
expect(wrapper.find(EuiButton)).toHaveLength(1);
expect(wrapper.find(EuiButtonEmpty)).toHaveLength(1);
expect(deleteHandler).toHaveBeenCalledTimes(0);
});

test('it shows a confirmation dialog when clicked', () => {
const deleteHandler = jest.fn();
const wrapper = mount(<DeleteRoleButton canDelete={true} onDelete={deleteHandler} />);

wrapper.find(EuiButton).simulate('click');
wrapper.find(EuiButtonEmpty).simulate('click');

expect(wrapper.find(EuiConfirmModal)).toHaveLength(1);

Expand Down
Loading