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] - Reactify roles screen #19035

Merged
merged 43 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
67e05db
round 1
legrego May 11, 2018
904a6b7
validation and cleanup
legrego May 14, 2018
8ae7325
Fix react warnings
legrego May 14, 2018
2c70cc1
Hook UI actions to API
legrego May 14, 2018
036c4e4
adds some testing
legrego May 14, 2018
378e78c
replace spaces with dashes when typing role name
legrego May 14, 2018
d888a93
use new isDisabled prop for EuiComoBoxes
legrego May 15, 2018
63028de
Update version of EUI to get disable-able ComboBox components
legrego May 15, 2018
5f0688b
Merge branch 'rbac-phase-1' into reactify-roles-screen
legrego May 16, 2018
3984c2b
working port from rbac-phase-1
legrego May 16, 2018
4f39d2b
refactor permission components
legrego May 16, 2018
918cca4
combine role utils into a single file
legrego May 16, 2018
fcc7432
add index.js to components directory
legrego May 16, 2018
74e1d4a
Improve form validation
legrego May 17, 2018
92812e5
Fixes #18166 : warn when no fields are granted
legrego May 18, 2018
f50db3f
Merge branch 'spaces-phase-1' into reactify-roles-screen
legrego May 21, 2018
b6d1b9a
Disable certain edits for Reserved Spaces
legrego May 21, 2018
36e7a67
Adding built-in types and alphabetizing (#19306)
kobelb May 22, 2018
06eb784
Filtering out non-default resource Kibana privileges (#19321)
kobelb May 22, 2018
74891fd
Initial design refactor of edit roles screen
legrego May 25, 2018
ad0ec04
improved ui for reserved roles
legrego May 25, 2018
ebf85d8
create CollapsiblePanel component for roles screen
legrego May 25, 2018
a826ee5
Improve readonly view
legrego May 29, 2018
d188dc8
Fix save logic
legrego May 29, 2018
4464482
Re-add granted fields warning
legrego May 29, 2018
767fb27
Removing unused file
kobelb May 29, 2018
0baea66
Merge branch 'rbac-phase-1' into reactify-roles-screen
legrego May 29, 2018
ebd09d1
additional tests
legrego May 29, 2018
642eaae
port remainder of index privs logic, and remove angular version of th…
legrego May 29, 2018
009c29f
additional tests and a bugfix
legrego May 30, 2018
d0c44e9
remove unused code
legrego May 30, 2018
c5366f6
address PR feedback
legrego May 30, 2018
abb55d7
improve role validation
legrego May 30, 2018
cb02fe1
Design edits
cchaos May 31, 2018
87f8cd8
start addressing design feedback
legrego Jun 1, 2018
bb1c129
Don't hide delete button for placeholder privileges
legrego Jun 1, 2018
829a6e7
change Kibana Privileges to use a select instead of checkboxes
legrego Jun 1, 2018
c777670
upgrade to EUI 0.0.51, and fix Role breadcrumbs
legrego Jun 1, 2018
b05d937
fix doc links
legrego Jun 5, 2018
d901b52
Merge branch 'reactify-roles-screen' into legrego-reactify-roles-screen
legrego Jun 5, 2018
4283e29
Merge pull request #2 from cchaos/legrego-reactify-roles-screen
legrego Jun 5, 2018
6adfe2a
Fix tests and cleanup unused code
legrego Jun 5, 2018
e739e5c
design updates
legrego Jun 7, 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
5 changes: 4 additions & 1 deletion x-pack/plugins/security/public/documentation_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';

export const documentationLinks = {
dashboardViewMode: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/xpack-view-modes.html`
dashboardViewMode: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/xpack-view-modes.html`,
esClusterPrivileges: `${ELASTIC_WEBSITE_URL}guide/en/x-pack/current/security-privileges.html#security-privileges`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we aren't using ${DOC_LINK_VERSION} in place of current? Generally we try to make the doc links in Kibana point to the specific version, so that 6.3 of Kibana always links to 6.3 of the docs, this helps to prevent dead-links from occurring or linking to docs that are incorrect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gah how did I let that happen? Good catch, will fix!

esIndicesPrivileges: `${ELASTIC_WEBSITE_URL}guide/en/x-pack/current/security-privileges.html#privileges-list-indices`,
esRunAsPrivileges: `${ELASTIC_WEBSITE_URL}guide/en/x-pack/current/security-privileges.html#_run_as_privilege`,
};
35 changes: 0 additions & 35 deletions x-pack/plugins/security/public/lib/__tests__/role.js

This file was deleted.

11 changes: 10 additions & 1 deletion x-pack/plugins/security/public/lib/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ import { get } from 'lodash';
*/
export function isRoleEnabled(role) {
return get(role, 'transient_metadata.enabled', true);
}
}

/**
* Returns whether given role is reserved or not.
*
* @param {role} the Role as returned by roles API
*/
export function isReservedRole(role) {
return get(role, 'metadata._reserved', false);
}
59 changes: 59 additions & 0 deletions x-pack/plugins/security/public/lib/role.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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 { isRoleEnabled, isReservedRole } from './role';

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

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

test('should return true if role is NOT explicitly enabled or disabled', () => {
const testRole = {};
expect(isRoleEnabled(testRole)).toBe(true);
});
});

describe('isReservedRole', () => {
test('should return false if role is explicitly not reserved', () => {
const testRole = {
metadata: {
_reserved: false
}
};
expect(isReservedRole(testRole)).toBe(false);
});

test('should return true if role is explicitly reserved', () => {
const testRole = {
metadata: {
_reserved: true
}
};
expect(isReservedRole(testRole)).toBe(true);
});

test('should return false if role is NOT explicitly reserved or not reserved', () => {
const testRole = {};
expect(isReservedRole(testRole)).toBe(false);
});
});
});
9 changes: 9 additions & 0 deletions x-pack/plugins/security/public/objects/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 { saveRole, deleteRole } from './lib/roles';

export { getFields } from './lib/get_fields';
14 changes: 14 additions & 0 deletions x-pack/plugins/security/public/objects/lib/get_fields.js
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.
*/
import chrome from 'ui/chrome';

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

export async function getFields($http, query) {
return await $http
.get(`${apiBase}/${query}`)
.then(response => response.data || []);
}
16 changes: 16 additions & 0 deletions x-pack/plugins/security/public/objects/lib/roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 chrome from 'ui/chrome';

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

export async function saveRole($http, role) {
return await $http.post(`${apiBase}/${role.name}`, role);
}

export async function deleteRole($http, name) {
return await $http.delete(`${apiBase}/${name}`);
}
13 changes: 13 additions & 0 deletions x-pack/plugins/security/public/objects/role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 class Role {
name = null;
cluster = [];
indices = [];
run_as = []; //eslint-disable-line camelcase
applications = [];
}
42 changes: 42 additions & 0 deletions x-pack/plugins/security/public/services/role_privileges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/

const clusterPrivileges = [
'all',
'monitor',
'manage',
'manage_security',
'manage_index_templates',
'manage_pipeline',
'manage_ingest_pipelines',
'transport_client',
'manage_ml',
'monitor_ml',
'manage_watcher',
'monitor_watcher',
];
const indexPrivileges = [
'all',
'manage',
'monitor',
'read',
'index',
'create',
'delete',
'write',
'delete_index',
'create_index',
'view_index_metadata',
'read_cross_cluster',
];

export function getClusterPrivileges() {
return [...clusterPrivileges];
}

export function getIndexPrivileges() {
return [...indexPrivileges];
}
Loading