[Files] Add default file kind (#144803)

## Summary

Introduce a default file kind for images in Kibana. This file kind will
be the download/upload target usable for all images across Kibana.
Consider the following:

A Kibana user wants to add a branding logo to their dashboard. They need
to create a new image or select from a set of existing images (i.e.,
images already uploaded). This set of images is the "default image" set.
The idea will be this set of images can be access across dashboards and
solutions. For example, the same user can access the branding image they
uploaded in Cases.

## How it works

* We added a new default file kind specifically for images, this is
registered from the files plugin
* In order to access these files over HTTP users will need the
`files:defaultImage` privilege
* This is a distinct privilege from the file management privilege and
allows users to access HTTP endpoints controlled by
`access:files:defaultImage` as well as the underlying `file` saved
object
* Consider a dashboard user that wants to add an image embeddable: they
will need access to `file` saved object as well as the endpoints for
creating/reading/deleting the default file kind. In order to get this
their role must grant the new "Shared images" privilege.

<img width="749" alt="Screenshot 2022-11-22 at 10 34 25"
src="https://user-images.githubusercontent.com/8155004/203295230-24a0be94-9c59-4a53-8757-336e9fc8f6c4.png">
This commit is contained in:
Jean-Louis Leysens 2022-11-23 12:37:05 +01:00 committed by GitHub
parent b6dcb8b088
commit 6de90aab9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 202 additions and 8 deletions

View file

@ -169,6 +169,10 @@ Array [
"id": "filesManagement",
"subFeatures": undefined,
},
Object {
"id": "filesSharedImage",
"subFeatures": undefined,
},
Object {
"id": "savedObjectsManagement",
"subFeatures": undefined,
@ -457,6 +461,10 @@ Array [
"id": "filesManagement",
"subFeatures": undefined,
},
Object {
"id": "filesSharedImage",
"subFeatures": undefined,
},
Object {
"id": "savedObjectsManagement",
"subFeatures": undefined,
@ -773,6 +781,7 @@ Array [
"privilege": Object {
"api": Array [
"files:manageFiles",
"files:defaultImage",
],
"app": Array [
"kibana",
@ -784,7 +793,8 @@ Array [
},
"savedObject": Object {
"all": Array [
"files",
"file",
"fileShare",
],
"read": Array [],
},
@ -796,6 +806,7 @@ Array [
"privilege": Object {
"api": Array [
"files:manageFiles",
"files:defaultImage",
],
"app": Array [
"kibana",
@ -808,7 +819,49 @@ Array [
"savedObject": Object {
"all": Array [],
"read": Array [
"files",
"file",
"fileShare",
],
},
"ui": Array [],
},
"privilegeId": "read",
},
]
`;
exports[`buildOSSFeatures with a basic license returns the filesSharedImage feature augmented with appropriate sub feature privileges 1`] = `
Array [
Object {
"privilege": Object {
"api": Array [
"files:defaultImage",
],
"app": Array [
"kibana",
],
"savedObject": Object {
"all": Array [
"file",
],
"read": Array [],
},
"ui": Array [],
},
"privilegeId": "all",
},
Object {
"privilege": Object {
"api": Array [
"files:defaultImage",
],
"app": Array [
"kibana",
],
"savedObject": Object {
"all": Array [],
"read": Array [
"file",
],
},
"ui": Array [],
@ -1332,6 +1385,7 @@ Array [
"privilege": Object {
"api": Array [
"files:manageFiles",
"files:defaultImage",
],
"app": Array [
"kibana",
@ -1343,7 +1397,8 @@ Array [
},
"savedObject": Object {
"all": Array [
"files",
"file",
"fileShare",
],
"read": Array [],
},
@ -1355,6 +1410,7 @@ Array [
"privilege": Object {
"api": Array [
"files:manageFiles",
"files:defaultImage",
],
"app": Array [
"kibana",
@ -1367,7 +1423,49 @@ Array [
"savedObject": Object {
"all": Array [],
"read": Array [
"files",
"file",
"fileShare",
],
},
"ui": Array [],
},
"privilegeId": "read",
},
]
`;
exports[`buildOSSFeatures with a enterprise license returns the filesSharedImage feature augmented with appropriate sub feature privileges 1`] = `
Array [
Object {
"privilege": Object {
"api": Array [
"files:defaultImage",
],
"app": Array [
"kibana",
],
"savedObject": Object {
"all": Array [
"file",
],
"read": Array [],
},
"ui": Array [],
},
"privilegeId": "all",
},
Object {
"privilege": Object {
"api": Array [
"files:defaultImage",
],
"app": Array [
"kibana",
],
"savedObject": Object {
"all": Array [],
"read": Array [
"file",
],
},
"ui": Array [],

View file

@ -441,11 +441,11 @@ export const buildOSSFeatures = ({
kibana: ['filesManagement'],
},
savedObject: {
all: ['files'],
all: ['file', 'fileShare'],
read: [],
},
ui: [],
api: ['files:manageFiles'],
api: ['files:manageFiles', 'files:defaultImage'],
},
read: {
app: ['kibana'],
@ -454,10 +454,43 @@ export const buildOSSFeatures = ({
},
savedObject: {
all: [],
read: ['files'],
read: ['file', 'fileShare'],
},
ui: [],
api: ['files:manageFiles'],
api: ['files:manageFiles', 'files:defaultImage'],
},
},
},
{
id: 'filesSharedImage',
name: i18n.translate('xpack.features.filesSharedImagesFeatureName', {
defaultMessage: 'Shared images',
}),
order: 1600,
category: DEFAULT_APP_CATEGORIES.management,
app: ['kibana'],
catalogue: [],
privilegesTooltip: i18n.translate('xpack.features.filesSharedImagesPrivilegesTooltip', {
defaultMessage: 'Required to access images stored in Kibana.',
}),
privileges: {
all: {
app: ['kibana'],
savedObject: {
all: ['file'],
read: [],
},
ui: [],
api: ['files:defaultImage'],
},
read: {
app: ['kibana'],
savedObject: {
all: [],
read: ['file'],
},
ui: [],
api: ['files:defaultImage'],
},
},
},

View file

@ -67,6 +67,7 @@ describe('Features Plugin', () => {
"advancedSettings",
"indexPatterns",
"filesManagement",
"filesSharedImage",
"savedObjectsManagement",
]
`);