AccessControl: Add accesscontrol metadata to datasources DTOs (#42675)
* AccessControl: Provide scope to frontend * Covering datasources with accesscontrol metadata * Write benchmark tests for GetResourcesMetadata * Add accesscontrol util and interface * Add the hasPermissionInMetadata function in the frontend access control code * Use IsDisabled rather that performing a feature toggle check Co-authored-by: Karl Persson <kalle.persson@grafana.com>
This commit is contained in:
co-authored by
Karl Persson
parent
2b1ed43cb2
commit
c7cabdfd6f
@@ -0,0 +1,14 @@
|
||||
import { KeyValue } from '.';
|
||||
|
||||
/**
|
||||
* With FGAC, the backend will return additional access control metadata to objects.
|
||||
* These metadata will contain user permissions associated to a given resource.
|
||||
*
|
||||
* For example:
|
||||
* {
|
||||
* accessControl: { "datasources:read": true, "datasources:write": true }
|
||||
* }
|
||||
*/
|
||||
export interface WithAccessControlMetadata {
|
||||
accessControl?: KeyValue<boolean>;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { CoreApp } from './app';
|
||||
import { CustomVariableSupport, DataSourceVariableSupport, StandardVariableSupport } from './variables';
|
||||
import { makeClassES5Compatible } from '../utils/makeClassES5Compatible';
|
||||
import { DataQuery } from './query';
|
||||
import { DataSourceRef } from '.';
|
||||
import { DataSourceRef, WithAccessControlMetadata } from '.';
|
||||
|
||||
export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonData, SecureJSONData = {}> {
|
||||
options: DataSourceSettings<JSONData, SecureJSONData>;
|
||||
@@ -540,7 +540,8 @@ export interface DataSourceJsonData {
|
||||
* Data Source instance edit model. This is returned from:
|
||||
* /api/datasources
|
||||
*/
|
||||
export interface DataSourceSettings<T extends DataSourceJsonData = DataSourceJsonData, S = {}> {
|
||||
export interface DataSourceSettings<T extends DataSourceJsonData = DataSourceJsonData, S = {}>
|
||||
extends WithAccessControlMetadata {
|
||||
id: number;
|
||||
uid: string;
|
||||
orgId: number;
|
||||
|
||||
@@ -39,3 +39,4 @@ export { isUnsignedPluginSignature } from './pluginSignature';
|
||||
export { GrafanaConfig, BuildInfo, FeatureToggles, LicenseInfo, PreloadPlugin } from './config';
|
||||
export * from './alerts';
|
||||
export * from './slider';
|
||||
export * from './accesscontrol';
|
||||
|
||||
Reference in New Issue
Block a user