Skip to content

Commit

Permalink
Addressing second round of feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed Sep 3, 2020
1 parent 19e1e00 commit 987c6f4
Show file tree
Hide file tree
Showing 9 changed files with 913 additions and 75 deletions.
940 changes: 899 additions & 41 deletions x-pack/plugins/security/server/authorization/check_privileges.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ export function disableUICapabilitiesFactory(
const isCatalogueFeature = featureId === 'catalogue';
const isManagementFeature = featureId === 'management';

let hasRequiredKibanaPrivileges = false;
if (!isElasticsearchFeature) {
hasRequiredKibanaPrivileges = checkPrivilegesResponse.privileges.kibana.some(
const hasRequiredKibanaPrivileges = checkPrivilegesResponse.privileges.kibana.some(
(x) => x.privilege === action && x.authorized === true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeApiBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
if (privilegeDefinition.api) {
return privilegeDefinition.api.map((operation) => this.actions.api.get(operation));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeAppBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
const appIds = privilegeDefinition.app;

if (!appIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeCatalogueBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
const catalogueEntries = privilegeDefinition.catalogue;

if (!catalogueEntries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeManagementBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
const managementSections = privilegeDefinition.management;

if (!managementSections) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

export class FeaturePrivilegeNavlinkBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
return (privilegeDefinition.app ?? []).map((app) => this.actions.ui.get('navLinks', app));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
*/

import { flatten, uniq } from 'lodash';
import { KibanaFeature, FeatureKibanaPrivileges } from '../../../../../features/server';
import { FeatureKibanaPrivileges } from '../../../../../features/server';
import { BaseFeaturePrivilegeBuilder } from './feature_privilege_builder';

const readOperations: string[] = ['bulk_get', 'get', 'find'];
const writeOperations: string[] = ['create', 'bulk_create', 'update', 'bulk_update', 'delete'];
const allOperations: string[] = [...readOperations, ...writeOperations];

export class FeaturePrivilegeSavedObjectBuilder extends BaseFeaturePrivilegeBuilder {
public getActions(
privilegeDefinition: FeatureKibanaPrivileges,
feature: KibanaFeature
): string[] {
public getActions(privilegeDefinition: FeatureKibanaPrivileges): string[] {
return uniq([
...flatten(
privilegeDefinition.savedObject.all.map((type) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SubFeaturePrivilegeConfig } from '../../../../../features/common';
import { KibanaFeature } from '../../../../../features/server';
import { KibanaFeature, SubFeaturePrivilegeConfig } from '../../../../../features/common';

export function* subFeaturePrivilegeIterator(
feature: KibanaFeature
Expand Down

0 comments on commit 987c6f4

Please sign in to comment.