From 6908ff39ef59daa2c5508c74482cc8bb8353876c Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 28 Dec 2024 00:49:45 +1100 Subject: [PATCH] [8.x] Unauthorized route migration for routes owned by stack-monitoring (#198372) (#205196) # Backport This will backport the following commits from `main` to `8.x`: - [Unauthorized route migration for routes owned by stack-monitoring (#198372)](https://github.com/elastic/kibana/pull/198372) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../routes/api/v1/dynamic_route/get_metrics_by_type.ts | 7 +++++++ .../server/routes/api/v1/prometheus/get_metrics.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/dynamic_route/get_metrics_by_type.ts b/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/dynamic_route/get_metrics_by_type.ts index 95e1770826d6f..a128d14314052 100644 --- a/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/dynamic_route/get_metrics_by_type.ts +++ b/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/dynamic_route/get_metrics_by_type.ts @@ -36,6 +36,13 @@ export function registerDynamicRoute({ router.get( { path: `${MONITORING_COLLECTION_BASE_PATH}/{type}`, + security: { + authz: { + enabled: false, + reason: + 'This route is opted out from authorization because it is only retrieving the ES cluster UUID', + }, + }, options: { access: 'internal', authRequired: true, diff --git a/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/prometheus/get_metrics.ts b/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/prometheus/get_metrics.ts index 6977be155a4fb..ccc8465917679 100644 --- a/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/prometheus/get_metrics.ts +++ b/x-pack/platform/plugins/private/monitoring_collection/server/routes/api/v1/prometheus/get_metrics.ts @@ -20,6 +20,13 @@ export function registerV1PrometheusRoute({ router.get( { path: PROMETHEUS_PATH, + security: { + authz: { + enabled: false, + reason: + 'This route is opted out from authorization because it is not interacting with ES at all', + }, + }, options: { authRequired: true, tags: ['api'], // ensures that unauthenticated calls receive a 401 rather than a 302 redirect to login page