kibana/x-pack/plugins/infra/server/features.ts
ymao1 71379b755a
[Alerting] Split alerting feature privilege between rules and alerts and handle subfeature privilege specification (#100127)
* WIP - creating alerting authorization client factory and exposing authorization client on plugin start contract

* Updating alerting feature privilege builder to handle different alerting types

* Passing in alerting authorization type to AlertingActions class string builder

* Passing in authorization type in each function call

* Passing in exempt consumer ids. Adding authorization type to audit logger

* Changing alertType to ruleType

* Changing alertType to ruleType

* Updating unit tests

* Updating unit tests

* Passing field names into authorization query builder. Adding kql/es dsl option

* Converting to es query if requested

* Fixing functional tests

* Removing ability to specify feature privilege name in constructor

* Fixing some types and tests

* Consolidating alerting authorization kuery filter options

* Cleanup and tests

* Cleanup and tests

* Initial commit with changes needed for subfeature privilege

* Throwing error when AlertingAuthorizationClientFactory is not defined

* Renaming authorizationType to entity

* Renaming AlertsAuthorization to AlertingAuthorization

* Fixing unit tests

* Changing schema of alerting feature privilege

* Changing schema of alerting feature privilege

* Updating feature privilege iterator

* Updating feature privilege builder

* Fixing types check

* Updating privilege string terminology

* Updating privilege string terminology

* Wip

* Fixing unit tests

* Unit tests

* Updating README and removing stack subfeature privilege changes

* Fixing README

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-05-27 14:59:02 -04:00

131 lines
3.7 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import { LOG_DOCUMENT_COUNT_ALERT_TYPE_ID } from '../common/alerting/logs/log_threshold/types';
import { METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID } from './lib/alerting/inventory_metric_threshold/types';
import { METRIC_THRESHOLD_ALERT_TYPE_ID } from './lib/alerting/metric_threshold/types';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
export const METRICS_FEATURE = {
id: 'infrastructure',
name: i18n.translate('xpack.infra.featureRegistry.linkInfrastructureTitle', {
defaultMessage: 'Metrics',
}),
order: 800,
category: DEFAULT_APP_CATEGORIES.observability,
app: ['infra', 'metrics', 'kibana'],
catalogue: ['infraops', 'metrics'],
management: {
insightsAndAlerting: ['triggersActions'],
},
alerting: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
privileges: {
all: {
app: ['infra', 'metrics', 'kibana'],
catalogue: ['infraops', 'metrics'],
api: ['infra'],
savedObject: {
all: ['infrastructure-ui-source'],
read: ['index-pattern'],
},
alerting: {
rule: {
all: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
},
alert: {
all: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
},
},
management: {
insightsAndAlerting: ['triggersActions'],
},
ui: ['show', 'configureSource', 'save'],
},
read: {
app: ['infra', 'metrics', 'kibana'],
catalogue: ['infraops', 'metrics'],
api: ['infra'],
savedObject: {
all: [],
read: ['infrastructure-ui-source', 'index-pattern'],
},
alerting: {
rule: {
read: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
},
alert: {
read: [METRIC_THRESHOLD_ALERT_TYPE_ID, METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID],
},
},
management: {
insightsAndAlerting: ['triggersActions'],
},
ui: ['show'],
},
},
};
export const LOGS_FEATURE = {
id: 'logs',
name: i18n.translate('xpack.infra.featureRegistry.linkLogsTitle', {
defaultMessage: 'Logs',
}),
order: 700,
category: DEFAULT_APP_CATEGORIES.observability,
app: ['infra', 'logs', 'kibana'],
catalogue: ['infralogging', 'logs'],
management: {
insightsAndAlerting: ['triggersActions'],
},
alerting: [LOG_DOCUMENT_COUNT_ALERT_TYPE_ID],
privileges: {
all: {
app: ['infra', 'logs', 'kibana'],
catalogue: ['infralogging', 'logs'],
api: ['infra'],
savedObject: {
all: ['infrastructure-ui-source'],
read: [],
},
alerting: {
rule: {
all: [LOG_DOCUMENT_COUNT_ALERT_TYPE_ID],
},
alert: {
all: [LOG_DOCUMENT_COUNT_ALERT_TYPE_ID],
},
},
management: {
insightsAndAlerting: ['triggersActions'],
},
ui: ['show', 'configureSource', 'save'],
},
read: {
app: ['infra', 'logs', 'kibana'],
catalogue: ['infralogging', 'logs'],
api: ['infra'],
alerting: {
rule: {
read: [LOG_DOCUMENT_COUNT_ALERT_TYPE_ID],
},
alert: {
read: [LOG_DOCUMENT_COUNT_ALERT_TYPE_ID],
},
},
management: {
insightsAndAlerting: ['triggersActions'],
},
savedObject: {
all: [],
read: ['infrastructure-ui-source'],
},
ui: ['show'],
},
},
};