Skip to content

Commit af0f291

Browse files
authored
[So tagging] Add automatic read privileges for "tag" SO type (#202400)
1 parent d6cfd3f commit af0f291

File tree

9 files changed

+245
-38
lines changed

9 files changed

+245
-38
lines changed

x-pack/plugins/features/server/feature_registry.test.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ describe('FeatureRegistry', () => {
5757
app: ['app1'],
5858
savedObject: {
5959
all: ['space', 'etc', 'telemetry'],
60-
read: ['canvas', 'config', 'config-global', 'url'],
60+
read: ['canvas', 'config', 'config-global', 'url', 'tag'],
6161
},
6262
api: ['someApiEndpointTag', 'anotherEndpointTag'],
6363
ui: ['allowsFoo', 'showBar', 'showBaz'],
6464
},
6565
read: {
6666
savedObject: {
6767
all: [],
68-
read: ['config', 'config-global', 'url', 'telemetry'],
68+
read: ['config', 'config-global', 'url', 'telemetry', 'tag'],
6969
},
7070
ui: [],
7171
},
@@ -130,7 +130,7 @@ describe('FeatureRegistry', () => {
130130
app: ['app1'],
131131
savedObject: {
132132
all: ['space', 'etc', 'telemetry'],
133-
read: ['canvas', 'config', 'config-global', 'url'],
133+
read: ['canvas', 'config', 'config-global', 'url', 'tag'],
134134
},
135135
api: ['someApiEndpointTag', 'anotherEndpointTag'],
136136
ui: ['allowsFoo', 'showBar', 'showBaz'],
@@ -314,7 +314,7 @@ describe('FeatureRegistry', () => {
314314
expect(allPrivilege?.savedObject.all).toEqual(['telemetry']);
315315
});
316316

317-
it(`automatically grants access to config, config-global, url, and telemetry saved objects`, () => {
317+
it(`automatically grants access to config, config-global, url, telemetry and tag saved objects`, () => {
318318
const feature: KibanaFeatureConfig = {
319319
id: 'test-feature',
320320
name: 'Test Feature',
@@ -348,16 +348,17 @@ describe('FeatureRegistry', () => {
348348

349349
const allPrivilege = result[0].privileges?.all;
350350
const readPrivilege = result[0].privileges?.read;
351-
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url']);
351+
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url', 'tag']);
352352
expect(readPrivilege?.savedObject.read).toEqual([
353353
'config',
354354
'config-global',
355355
'telemetry',
356356
'url',
357+
'tag',
357358
]);
358359
});
359360

360-
it(`automatically grants 'all' access to telemetry and 'read' to [config, config-global, url] saved objects for the reserved privilege`, () => {
361+
it(`automatically grants 'all' access to telemetry and 'read' to [config, config-global, url, tag] saved objects for the reserved privilege`, () => {
361362
const feature: KibanaFeatureConfig = {
362363
id: 'test-feature',
363364
name: 'Test Feature',
@@ -388,7 +389,7 @@ describe('FeatureRegistry', () => {
388389

389390
const reservedPrivilege = result[0]!.reserved!.privileges[0].privilege;
390391
expect(reservedPrivilege.savedObject.all).toEqual(['telemetry']);
391-
expect(reservedPrivilege.savedObject.read).toEqual(['config', 'config-global', 'url']);
392+
expect(reservedPrivilege.savedObject.read).toEqual(['config', 'config-global', 'url', 'tag']);
392393
});
393394

394395
it(`does not duplicate the automatic grants if specified on the incoming feature`, () => {
@@ -402,14 +403,14 @@ describe('FeatureRegistry', () => {
402403
ui: [],
403404
savedObject: {
404405
all: ['telemetry'],
405-
read: ['config', 'config-global', 'url'],
406+
read: ['config', 'config-global', 'url', 'tag'],
406407
},
407408
},
408409
read: {
409410
ui: [],
410411
savedObject: {
411412
all: [],
412-
read: ['config', 'config-global', 'url'],
413+
read: ['config', 'config-global', 'url', 'tag'],
413414
},
414415
},
415416
},
@@ -426,11 +427,12 @@ describe('FeatureRegistry', () => {
426427
const allPrivilege = result[0].privileges!.all;
427428
const readPrivilege = result[0].privileges!.read;
428429
expect(allPrivilege?.savedObject.all).toEqual(['telemetry']);
429-
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url']);
430+
expect(allPrivilege?.savedObject.read).toEqual(['config', 'config-global', 'url', 'tag']);
430431
expect(readPrivilege?.savedObject.read).toEqual([
431432
'config',
432433
'config-global',
433434
'url',
435+
'tag',
434436
'telemetry',
435437
]);
436438
});
@@ -518,7 +520,7 @@ describe('FeatureRegistry', () => {
518520
name: 'Foo',
519521
app: ['app1', 'app2'],
520522
savedObject: {
521-
all: ['config', 'config-global', 'space', 'etc'],
523+
all: ['config', 'config-global', 'space', 'tag', 'etc'],
522524
read: ['canvas'],
523525
},
524526
api: ['someApiEndpointTag', 'anotherEndpointTag'],
@@ -2455,15 +2457,15 @@ describe('FeatureRegistry', () => {
24552457
expect(featureA.privileges).toEqual({
24562458
all: {
24572459
ui: [],
2458-
savedObject: { all: ['telemetry'], read: ['config', 'config-global', 'url'] },
2460+
savedObject: { all: ['telemetry'], read: ['config', 'config-global', 'url', 'tag'] },
24592461
composedOf: [
24602462
{ feature: 'featureC', privileges: ['subFeatureCOne'] },
24612463
{ feature: 'featureD', privileges: ['all'] },
24622464
],
24632465
},
24642466
read: {
24652467
ui: [],
2466-
savedObject: { all: [], read: ['config', 'config-global', 'telemetry', 'url'] },
2468+
savedObject: { all: [], read: ['config', 'config-global', 'telemetry', 'url', 'tag'] },
24672469
composedOf: [{ feature: 'featureD', privileges: ['read'] }],
24682470
},
24692471
});
@@ -2483,12 +2485,12 @@ describe('FeatureRegistry', () => {
24832485
expect(featureA.privileges).toEqual({
24842486
all: {
24852487
ui: [],
2486-
savedObject: { all: ['telemetry'], read: ['config', 'config-global', 'url'] },
2488+
savedObject: { all: ['telemetry'], read: ['config', 'config-global', 'url', 'tag'] },
24872489
composedOf: [{ feature: 'featureE', privileges: ['all'] }],
24882490
},
24892491
read: {
24902492
ui: [],
2491-
savedObject: { all: [], read: ['config', 'config-global', 'telemetry', 'url'] },
2493+
savedObject: { all: [], read: ['config', 'config-global', 'telemetry', 'url', 'tag'] },
24922494
},
24932495
});
24942496
});

x-pack/plugins/features/server/feature_registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ function applyAutomaticAllPrivilegeGrants(
340340
'config',
341341
'config-global',
342342
'url',
343+
'tag',
343344
]);
344345
}
345346
});
@@ -356,6 +357,7 @@ function applyAutomaticReadPrivilegeGrants(
356357
'config-global',
357358
'telemetry',
358359
'url',
360+
'tag',
359361
]);
360362
}
361363
});

x-pack/plugins/features/server/plugin.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ describe('Features Plugin', () => {
168168
"config",
169169
"config-global",
170170
"url",
171+
"tag",
171172
],
172173
},
173174
"ui": Array [],
@@ -183,6 +184,7 @@ describe('Features Plugin', () => {
183184
"config-global",
184185
"telemetry",
185186
"url",
187+
"tag",
186188
],
187189
},
188190
"ui": Array [],

x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/_find.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ export default function (ftrContext: FtrProviderContext) {
8080
USERS.DEFAULT_SPACE_DASHBOARD_READ_USER,
8181
USERS.DEFAULT_SPACE_VISUALIZE_READ_USER,
8282
USERS.DEFAULT_SPACE_MAPS_READ_USER,
83+
USERS.DEFAULT_SPACE_ADVANCED_SETTINGS_READ_USER,
8384
],
84-
noResults: [USERS.DEFAULT_SPACE_ADVANCED_SETTINGS_READ_USER],
85+
noResults: [],
8586
unauthorized: [USERS.NOT_A_KIBANA_USER],
8687
};
8788

x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function (ftrContext: FtrProviderContext) {
6969
USERS.DEFAULT_SPACE_VISUALIZE_READ_USER,
7070
USERS.DEFAULT_SPACE_MAPS_READ_USER,
7171
],
72-
unauthorized: [USERS.NOT_A_KIBANA_USER, USERS.DEFAULT_SPACE_ADVANCED_SETTINGS_READ_USER],
72+
unauthorized: [USERS.NOT_A_KIBANA_USER],
7373
};
7474

7575
const createUserTest = (

x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/get_all.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function (ftrContext: FtrProviderContext) {
8686
USERS.DEFAULT_SPACE_VISUALIZE_READ_USER,
8787
USERS.DEFAULT_SPACE_MAPS_READ_USER,
8888
],
89-
unauthorized: [USERS.NOT_A_KIBANA_USER, USERS.DEFAULT_SPACE_ADVANCED_SETTINGS_READ_USER],
89+
unauthorized: [USERS.NOT_A_KIBANA_USER],
9090
};
9191

9292
const createUserTest = (

0 commit comments

Comments
 (0)