Skip to content

Commit

Permalink
Hacking the privileges model
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Dec 4, 2020
1 parent 9985667 commit 0dc39a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 8 additions & 5 deletions x-pack/plugins/features/server/oss_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
*/
import { i18n } from '@kbn/i18n';
import { KibanaFeatureConfig } from '../common';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
import { DEFAULT_APP_CATEGORIES, ISavedObjectTypeRegistry } from '../../../../src/core/server';

export interface BuildOSSFeaturesParams {
savedObjectTypes: string[];
savedObjectTypeRegistry: ISavedObjectTypeRegistry;
includeTimelion: boolean;
}

export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSSFeaturesParams) => {
export const buildOSSFeatures = ({
savedObjectTypeRegistry,
includeTimelion,
}: BuildOSSFeaturesParams) => {
return [
{
id: 'discover',
Expand Down Expand Up @@ -346,7 +349,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
},
api: ['copySavedObjectsToSpaces'],
savedObject: {
all: [...savedObjectTypes],
all: [...savedObjectTypeRegistry.getImportableAndExportableTypes().map((t) => t.name)],
read: [],
},
ui: ['read', 'edit', 'delete', 'copyIntoSpace', 'shareIntoSpace'],
Expand All @@ -360,7 +363,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS
api: ['copySavedObjectsToSpaces'],
savedObject: {
all: [],
read: [...savedObjectTypes],
read: [...savedObjectTypeRegistry.getImportableAndExportableTypes().map((t) => t.name)],
},
ui: ['read'],
},
Expand Down
11 changes: 3 additions & 8 deletions x-pack/plugins/features/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,11 @@ export class Plugin {
public stop() {}

private registerOssFeatures(savedObjects: SavedObjectsServiceStart) {
const registry = savedObjects.getTypeRegistry();
const savedObjectTypes = registry.getVisibleTypes().map((t) => t.name);
const savedObjectTypeRegistry = savedObjects.getTypeRegistry();

this.logger.debug(
`Registering OSS features with SO types: ${savedObjectTypes.join(', ')}. "includeTimelion": ${
this.isTimelionEnabled
}.`
);
this.logger.debug(`Registering OSS features. "includeTimelion": ${this.isTimelionEnabled}.`);
const features = buildOSSFeatures({
savedObjectTypes,
savedObjectTypeRegistry,
includeTimelion: this.isTimelionEnabled,
});

Expand Down

0 comments on commit 0dc39a8

Please sign in to comment.