Skip to content

Commit

Permalink
[8.x] [upgrade assistant] Add authz info to REST api endpoints (#205071
Browse files Browse the repository at this point in the history
…) (#205597)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[upgrade assistant] Add authz info to REST api endpoints
(#205071)](#205071)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Matthew
Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-06T11:43:30Z","message":"[upgrade
assistant] Add authz info to REST api endpoints (#205071)\n\n##
Summary\r\n\r\nSimply adding `authz` info to REST endpoints as part
of\r\nhttps://github.com//pull/204531","sha":"4eb900651a97fe117b147e3737ad9dc3d9ee4a12","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","Feature:Upgrade
Assistant","v9.0.0","backport:prev-minor"],"title":"[upgrade assistant]
Add authz info to REST api
endpoints","number":205071,"url":"https://github.com/elastic/kibana/pull/205071","mergeCommit":{"message":"[upgrade
assistant] Add authz info to REST api endpoints (#205071)\n\n##
Summary\r\n\r\nSimply adding `authz` info to REST endpoints as part
of\r\nhttps://github.com//pull/204531","sha":"4eb900651a97fe117b147e3737ad9dc3d9ee4a12"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205071","number":205071,"mergeCommit":{"message":"[upgrade
assistant] Add authz info to REST api endpoints (#205071)\n\n##
Summary\r\n\r\nSimply adding `authz` info to REST endpoints as part
of\r\nhttps://github.com//pull/204531","sha":"4eb900651a97fe117b147e3737ad9dc3d9ee4a12"}}]}]
BACKPORT-->

Co-authored-by: Matthew Kime <[email protected]>
  • Loading branch information
kibanamachine and mattkime authored Jan 6, 2025
1 parent 88dad1b commit d34a221
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export function registerAppRoutes({
router.get(
{
path: `${API_BASE_PATH}/privileges`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ export function registerCloudBackupStatusRoutes({
}: RouteDependencies) {
// GET most recent Cloud snapshot
router.get(
{ path: `${API_BASE_PATH}/cloud_backup_status`, validate: false },
{
path: `${API_BASE_PATH}/cloud_backup_status`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async (context, request, response) => {
const { client: clusterClient } = (await context.core).elasticsearch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export function registerClusterSettingsRoute({
router.post(
{
path: `${API_BASE_PATH}/cluster_settings`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
body: schema.object({
settings: schema.arrayOf(schema.string()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ import { RouteDependencies } from '../types';

export function registerClusterUpgradeStatusRoutes({ router }: RouteDependencies) {
router.get(
{ path: `${API_BASE_PATH}/cluster_upgrade_status`, validate: false },
{
path: `${API_BASE_PATH}/cluster_upgrade_status`,
security: {
authz: {
enabled: false,
reason: 'Lightweight endpoint',
},
},
validate: false,
},
// We're just depending on the version check to return a 426.
// Otherwise we just return a 200.
versionCheckHandlerWrapper(async (context, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export function registerDeprecationLoggingRoutes({
router.get(
{
path: `${API_BASE_PATH}/deprecation_logging`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand All @@ -46,6 +52,12 @@ export function registerDeprecationLoggingRoutes({
router.put(
{
path: `${API_BASE_PATH}/deprecation_logging`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
body: schema.object({
isEnabled: schema.boolean(),
Expand All @@ -70,6 +82,12 @@ export function registerDeprecationLoggingRoutes({
router.get(
{
path: `${API_BASE_PATH}/deprecation_logging/count`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
query: schema.object({
from: schema.string(),
Expand Down Expand Up @@ -124,6 +142,12 @@ export function registerDeprecationLoggingRoutes({
router.delete(
{
path: `${API_BASE_PATH}/deprecation_logging/cache`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export function registerESDeprecationRoutes({
router.get(
{
path: `${API_BASE_PATH}/es_deprecations`,
security: {
authz: {
enabled: false,
reason: 'Relies on es and saved object clients for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export function registerMlSnapshotRoutes({
router.post(
{
path: `${API_BASE_PATH}/ml_snapshots`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
body: schema.object({
snapshotId: schema.string(),
Expand Down Expand Up @@ -195,6 +201,12 @@ export function registerMlSnapshotRoutes({
router.get(
{
path: `${API_BASE_PATH}/ml_snapshots/{jobId}/{snapshotId}`,
security: {
authz: {
enabled: false,
reason: 'Relies on es and saved object clients for authorization',
},
},
validate: {
params: schema.object({
snapshotId: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export function registerNodeDiskSpaceRoute({ router, lib: { handleEsError } }: R
router.get(
{
path: `${API_BASE_PATH}/node_disk_space`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export function registerBatchReindexIndicesRoutes(
router.get(
{
path: `${BASE_PATH}/batch/queue`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
options: {
access: 'public',
summary: `Get the batch reindex queue`,
Expand Down Expand Up @@ -75,6 +81,12 @@ export function registerBatchReindexIndicesRoutes(
router.post(
{
path: `${BASE_PATH}/batch`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
options: {
access: 'public',
summary: `Batch start or resume reindex`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export function registerReindexIndicesRoutes(
router.post(
{
path: `${BASE_PATH}/{indexName}`,
security: {
authz: {
enabled: false,
reason: 'Relies on es and saved object clients for authorization',
},
},
options: {
access: 'public',
summary: `Start or resume reindex`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export function registerRemoteClustersRoute({ router, lib: { handleEsError } }:
router.get(
{
path: `${API_BASE_PATH}/remote_clusters`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export function registerUpgradeStatusRoute({
router.get(
{
path: `${API_BASE_PATH}/status`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
options: {
access: 'public',
summary: `Get upgrade readiness status`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ export function registerSystemIndicesMigrationRoutes({
}: RouteDependencies) {
// GET status of the system indices migration
router.get(
{ path: `${API_BASE_PATH}/system_indices_migration`, validate: false },
{
path: `${API_BASE_PATH}/system_indices_migration`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
try {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export function registerUpdateSettingsRoute({ router }: RouteDependencies) {
router.post(
{
path: `${API_BASE_PATH}/{indexName}/index_settings`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
params: schema.object({
indexName: schema.string(),
Expand Down

0 comments on commit d34a221

Please sign in to comment.