Skip to content

Commit

Permalink
[8.x] [Kibana Management] Add missing API endpoint authz info (elasti…
Browse files Browse the repository at this point in the history
…c#209758) (elastic#210135)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Kibana Management] Add missing API endpoint authz info
(elastic#209758)](elastic#209758)

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

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

<!--BACKPORT [{"author":{"name":"Ignacio
Rivas","email":"rivasign@gmail.com"},"sourceCommit":{"committedDate":"2025-02-07T07:51:22Z","message":"[Kibana
Management] Add missing API endpoint authz info
(elastic#209758)","sha":"a468965588704f61a493eacd691da98877c177e2","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","backport:version","Authz:
API migration","v9.1.0","v8.19.0"],"title":"[Kibana Management] Add
missing API endpoint authz
info","number":209758,"url":"https://github.com/elastic/kibana/pull/209758","mergeCommit":{"message":"[Kibana
Management] Add missing API endpoint authz info
(elastic#209758)","sha":"a468965588704f61a493eacd691da98877c177e2"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209758","number":209758,"mergeCommit":{"message":"[Kibana
Management] Add missing API endpoint authz info
(elastic#209758)","sha":"a468965588704f61a493eacd691da98877c177e2"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
  • Loading branch information
kibanamachine and sabarasaba authored Feb 7, 2025
1 parent ce88180 commit f2b8944
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const registerConvertRequestRoute = ({
router.post(
{
path: '/api/console/convert_request_to_language',
security: {
authz: {
requiredPrivileges: ['console'],
},
},
validate: routeValidationConfig,
},
handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ export function registerMlSnapshotRoutes({
router.get(
{
path: `${API_BASE_PATH}/ml_upgrade_mode`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
versionCheckHandlerWrapper(async ({ core }, request, response) => {
Expand Down Expand Up @@ -387,6 +393,12 @@ export function registerMlSnapshotRoutes({
router.delete(
{
path: `${API_BASE_PATH}/ml_snapshots/{jobId}/{snapshotId}`,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
params: schema.object({
snapshotId: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export function registerReindexDataStreamRoutes({
access: 'public',
summary: `Get data stream status`,
},
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
params: schema.object({
dataStreamName: schema.string(),
Expand Down Expand Up @@ -144,6 +150,12 @@ export function registerReindexDataStreamRoutes({
access: 'public',
summary: `Get data stream reindexing metadata`,
},
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
params: schema.object({
dataStreamName: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ export function registerReindexIndicesRoutes(
access: 'public',
summary: `Get reindex status`,
},
security: {
authz: {
enabled: false,
reason: 'Relies on es and saved object clients for authorization',
},
},
validate: {
params: schema.object({
indexName: schema.string(),
Expand Down Expand Up @@ -152,6 +158,12 @@ export function registerReindexIndicesRoutes(
access: 'public',
summary: `Cancel reindex`,
},
security: {
authz: {
enabled: false,
reason: 'Relies on es and saved object clients for authorization',
},
},
validate: {
params: schema.object({
indexName: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ export function registerSystemIndicesMigrationRoutes({

// POST starts the system indices migration
router.post(
{ 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 @@ -35,6 +35,12 @@ export function registerAcknowledgeRoute({
router.put(
{
path: '/api/watcher/watch/{watchId}/action/{actionId}/acknowledge',
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: {
params: paramsSchema,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,35 @@ const paramsSchema = schema.object({

export const registerGetRoutes = ({ router, lib: { handleEsError } }: RouteDependencies): void => {
// Get all pipelines
router.get({ path: API_BASE_PATH, validate: false }, async (ctx, req, res) => {
const { client: clusterClient } = (await ctx.core).elasticsearch;
router.get(
{
path: API_BASE_PATH,
security: {
authz: {
enabled: false,
reason: 'Relies on es client for authorization',
},
},
validate: false,
},
async (ctx, req, res) => {
const { client: clusterClient } = (await ctx.core).elasticsearch;

try {
const pipelines = await clusterClient.asCurrentUser.ingest.getPipeline();
try {
const pipelines = await clusterClient.asCurrentUser.ingest.getPipeline();

return res.ok({ body: deserializePipelines(pipelines) });
} catch (error) {
const esErrorResponse = handleEsError({ error, response: res });
if (esErrorResponse.status === 404) {
// ES returns 404 when there are no pipelines
// Instead, we return an empty array and 200 status back to the client
return res.ok({ body: [] });
return res.ok({ body: deserializePipelines(pipelines) });
} catch (error) {
const esErrorResponse = handleEsError({ error, response: res });
if (esErrorResponse.status === 404) {
// ES returns 404 when there are no pipelines
// Instead, we return an empty array and 200 status back to the client
return res.ok({ body: [] });
}
return esErrorResponse;
}
return esErrorResponse;
}
});
);

// Get single pipeline
router.get(
Expand Down

0 comments on commit f2b8944

Please sign in to comment.