Skip to content

Commit 65a75ff

Browse files
Unauthorized route migration for routes owned by kibana-presentation (#198329)
Migrates unauthorized routes owned by the Presentation team to a new security configuration.
1 parent d7ef161 commit 65a75ff

File tree

21 files changed

+245
-20
lines changed

21 files changed

+245
-20
lines changed

src/plugins/controls/server/options_list/options_list_cluster_settings_route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export const setupOptionsListClusterSettingsRoute = ({ http }: CoreSetup) => {
2020
.addVersion(
2121
{
2222
version: '1',
23+
security: {
24+
authz: {
25+
enabled: false,
26+
reason:
27+
'This route is opted out from authorization because it does not take a query, params, or a body, so there is no chance of leaking info.',
28+
},
29+
},
2330
validate: false,
2431
},
2532
async (context, _, response) => {

src/plugins/controls/server/options_list/options_list_suggestions_route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export const setupOptionsListSuggestionsRoute = (
3333
.addVersion(
3434
{
3535
version: '1',
36+
security: {
37+
authz: {
38+
enabled: false,
39+
reason:
40+
'This route is opted out from authorization because permissions will be checked by elasticsearch.',
41+
},
42+
},
3643
validate: {
3744
request: {
3845
params: schema.object(

x-pack/plugins/canvas/server/routes/custom_elements/create.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export function initializeCreateCustomElementRoute(deps: RouteInitializerDeps) {
2929
.addVersion(
3030
{
3131
version: '1',
32+
security: {
33+
authz: {
34+
enabled: false,
35+
reason:
36+
'This route is opted out from authorization because authorization is provided by saved objects client.',
37+
},
38+
},
3239
validate: {
3340
request: { body: CustomElementSchema },
3441
},

x-pack/plugins/canvas/server/routes/custom_elements/delete.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export function initializeDeleteCustomElementRoute(deps: RouteInitializerDeps) {
2222
.addVersion(
2323
{
2424
version: '1',
25+
security: {
26+
authz: {
27+
enabled: false,
28+
reason:
29+
'This route is opted out from authorization because authorization is provided by saved objects client.',
30+
},
31+
},
2532
validate: {
2633
request: {
2734
params: schema.object({

x-pack/plugins/canvas/server/routes/custom_elements/find.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export function initializeFindCustomElementsRoute(deps: RouteInitializerDeps) {
2020
.addVersion(
2121
{
2222
version: '1',
23+
security: {
24+
authz: {
25+
enabled: false,
26+
reason:
27+
'This route is opted out from authorization because authorization is provided by saved objects client.',
28+
},
29+
},
2330
validate: {
2431
request: {
2532
query: schema.object({

x-pack/plugins/canvas/server/routes/custom_elements/get.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export function initializeGetCustomElementRoute(deps: RouteInitializerDeps) {
2121
.addVersion(
2222
{
2323
version: '1',
24+
security: {
25+
authz: {
26+
enabled: false,
27+
reason:
28+
'This route is opted out from authorization because authorization is provided by saved objects client.',
29+
},
30+
},
2431
validate: {
2532
request: {
2633
params: schema.object({

x-pack/plugins/canvas/server/routes/custom_elements/update.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export function initializeUpdateCustomElementRoute(deps: RouteInitializerDeps) {
3030
.addVersion(
3131
{
3232
version: '1',
33+
security: {
34+
authz: {
35+
enabled: false,
36+
reason:
37+
'This route is opted out from authorization because authorization is provided by saved objects client.',
38+
},
39+
},
3340
validate: {
3441
request: {
3542
params: schema.object({

x-pack/plugins/canvas/server/routes/functions/functions.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,26 @@ export function initializeGetFunctionsRoute(deps: RouteInitializerDeps) {
2323
path: API_ROUTE_FUNCTIONS,
2424
access: 'internal',
2525
})
26-
.addVersion({ version: '1', validate: false }, async (context, request, response) => {
27-
const functions = expressions.getFunctions('canvas');
28-
const body = JSON.stringify(functions);
29-
return response.ok({
30-
body,
31-
});
32-
});
26+
.addVersion(
27+
{
28+
version: '1',
29+
security: {
30+
authz: {
31+
enabled: false,
32+
reason:
33+
'This route is opted out from authorization because it only provides non-sensitive information about functions available to Canvas.',
34+
},
35+
},
36+
validate: false,
37+
},
38+
async (context, request, response) => {
39+
const functions = expressions.getFunctions('canvas');
40+
const body = JSON.stringify(functions);
41+
return response.ok({
42+
body,
43+
});
44+
}
45+
);
3346
}
3447

3548
export function initializeBatchFunctionsRoute(deps: RouteInitializerDeps) {
@@ -42,6 +55,13 @@ export function initializeBatchFunctionsRoute(deps: RouteInitializerDeps) {
4255
.addVersion(
4356
{
4457
version: '1',
58+
security: {
59+
authz: {
60+
enabled: false,
61+
reason:
62+
'This route is opted out from authorization because data source expressions that perform search operations use the Kibana search client which handles permission checking.',
63+
},
64+
},
4565
validate: {
4666
request: {
4767
body: schema.object({

x-pack/plugins/canvas/server/routes/shareables/download.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,29 @@ export function initializeDownloadShareableWorkpadRoute(deps: RouteInitializerDe
1818
path: API_ROUTE_SHAREABLE_RUNTIME_DOWNLOAD,
1919
access: 'internal',
2020
})
21-
.addVersion({ version: '1', validate: false }, async (_context, _request, response) => {
22-
// TODO: check if this is still an issue on cloud after migrating to NP
23-
//
24-
// The option setting is not for typical use. We're using it here to avoid
25-
// problems in Cloud environments. See elastic/kibana#47405.
26-
// const file = handler.file(SHAREABLE_RUNTIME_FILE, { confine: false });
27-
const file = readFileSync(SHAREABLE_RUNTIME_FILE);
28-
return response.ok({
29-
headers: { 'content-type': 'application/octet-stream' },
30-
body: file,
31-
});
32-
});
21+
.addVersion(
22+
{
23+
version: '1',
24+
security: {
25+
authz: {
26+
enabled: false,
27+
reason:
28+
'This route is opted out from authorization because it is only serving static files.',
29+
},
30+
},
31+
validate: false,
32+
},
33+
async (_context, _request, response) => {
34+
// TODO: check if this is still an issue on cloud after migrating to NP
35+
//
36+
// The option setting is not for typical use. We're using it here to avoid
37+
// problems in Cloud environments. See elastic/kibana#47405.
38+
// const file = handler.file(SHAREABLE_RUNTIME_FILE, { confine: false });
39+
const file = readFileSync(SHAREABLE_RUNTIME_FILE);
40+
return response.ok({
41+
headers: { 'content-type': 'application/octet-stream' },
42+
body: file,
43+
});
44+
}
45+
);
3346
}

x-pack/plugins/canvas/server/routes/shareables/zip.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ export function initializeZipShareableWorkpadRoute(deps: RouteInitializerDeps) {
2424
access: 'internal',
2525
})
2626
.addVersion(
27-
{ version: '1', validate: { request: { body: RenderedWorkpadSchema } } },
27+
{
28+
version: '1',
29+
security: {
30+
authz: {
31+
enabled: false,
32+
reason:
33+
'This route is opted out from authorization because it is only serving static files.',
34+
},
35+
},
36+
validate: { request: { body: RenderedWorkpadSchema } },
37+
},
2838
async (_context, request, response) => {
2939
const workpad = request.body;
3040
const archive = archiver('zip');

0 commit comments

Comments
 (0)