Skip to content

Commit

Permalink
Authorized route migration for routes owned by @elastic/kibana-core (e…
Browse files Browse the repository at this point in the history
…lastic#198187)

Co-authored-by: Alejandro Fernández Haro <[email protected]>
(cherry picked from commit 543cc2f)
  • Loading branch information
kibanamachine committed Nov 8, 2024
1 parent f132d6b commit 919eb55
Show file tree
Hide file tree
Showing 24 changed files with 83 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerBulkDeleteRoute = (router: IRouter) => {
router.post(
{
path: `${KBN_CLIENT_API_PREFIX}/_bulk_delete`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
body: schema.arrayOf(
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerCleanRoute = (router: IRouter) => {
router.post(
{
path: `${KBN_CLIENT_API_PREFIX}/_clean`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
body: schema.object({
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerCreateRoute = (router: IRouter) => {
router.post(
{
path: `${KBN_CLIENT_API_PREFIX}/{type}/{id?}`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
params: schema.object({
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerDeleteRoute = (router: IRouter) => {
router.delete(
{
path: `${KBN_CLIENT_API_PREFIX}/{type}/{id}`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
params: schema.object({
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerFindRoute = (router: IRouter) => {
router.get(
{
path: `${KBN_CLIENT_API_PREFIX}/_find`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
query: schema.object({
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerGetRoute = (router: IRouter) => {
router.get(
{
path: `${KBN_CLIENT_API_PREFIX}/{type}/{id}`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
params: schema.object({
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/ftr_apis/server/routes/kbn_client_so/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const registerUpdateRoute = (router: IRouter) => {
router.put(
{
path: `${KBN_CLIENT_API_PREFIX}/{type}/{id}`,
options: {
tags: ['access:ftrApis'],
security: {
authz: {
requiredPrivileges: ['ftrApis'],
},
},
validate: {
params: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export const defineBulkActionCspBenchmarkRulesRoute = (router: CspRouter) =>
.post({
access: 'internal',
path: CSP_BENCHMARK_RULES_BULK_ACTION_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-all'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-all'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export const defineFindCspBenchmarkRuleRoute = (router: CspRouter) =>
.get({
access: 'internal',
path: FIND_CSP_BENCHMARK_RULE_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const defineGetCspBenchmarkRulesStatesRoute = (router: CspRouter) =>
.get({
access: 'internal',
path: CSP_GET_BENCHMARK_RULES_STATE_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export const defineGetBenchmarksRoute = (router: CspRouter) =>
.get({
access: 'internal',
path: BENCHMARKS_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export const defineGetComplianceDashboardRoute = (router: CspRouter) =>
.get({
access: 'internal',
path: STATS_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export const defineGetDetectionEngineAlertsStatus = (router: CspRouter) =>
.get({
access: 'internal',
path: GET_DETECTION_RULE_ALERTS_STATUS_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export const defineGraphRoute = (router: CspRouter) =>
access: 'internal',
enableQueryVersion: true,
path: GRAPH_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,10 @@ export const defineGetCspStatusRoute = (
.get({
access: 'internal',
path: STATUS_ROUTE_PATH,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
})
.addVersion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export const defineGetVulnerabilitiesDashboardRoute = (router: CspRouter): void
{
path: VULNERABILITIES_DASHBOARD_ROUTE_PATH,
validate: false,
options: {
tags: ['access:cloud-security-posture-read'],
security: {
authz: {
requiredPrivileges: ['cloud-security-posture-read'],
},
},
},
async (context, request, response) => {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/features/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export function defineRoutes({ router, featureRegistry }: RouteDefinitionParams)
router.get(
{
path: '/api/features',
security: {
authz: {
requiredPrivileges: ['read_features'],
},
},
options: {
tags: ['access:read_features'],
access: 'public',
summary: `Get features`,
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/bulk_delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default function (ftrContext: FtrProviderContext) {
expect(body).to.eql({
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
message:
'API [POST /internal/ftr/kbn_client_so/_bulk_delete] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
});
},
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default function (ftrContext: FtrProviderContext) {
expectResponse: ({ body }) => {
expect(body).to.eql({
error: 'Forbidden',
message: 'Forbidden',
message:
'API [POST /internal/ftr/kbn_client_so/_clean] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
statusCode: 403,
});
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function (ftrContext: FtrProviderContext) {
expect(body).to.eql({
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
message:
'API [POST /internal/ftr/kbn_client_so/tag] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
});
},
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default function (ftrContext: FtrProviderContext) {
expect(body).to.eql({
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
message:
'API [DELETE /internal/ftr/kbn_client_so/visualization/vis-area-1] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
});
},
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default function (ftrContext: FtrProviderContext) {
expectResponse: ({ body }) => {
expect(body).to.eql({
error: 'Forbidden',
message: 'Forbidden',
message:
'API [GET /internal/ftr/kbn_client_so/_find?type=tag] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
statusCode: 403,
});
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default function (ftrContext: FtrProviderContext) {
expect(body).to.eql({
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
message:
'API [GET /internal/ftr/kbn_client_so/visualization/vis-area-4] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
});
},
},
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/ftr_apis/security_and_spaces/apis/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export default function (ftrContext: FtrProviderContext) {
expect(body).to.eql({
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
message:
'API [PUT /internal/ftr/kbn_client_so/tag/tag-1] is unauthorized for user, this action is granted by the Kibana privileges [ftrApis]',
});
},
},
Expand Down

0 comments on commit 919eb55

Please sign in to comment.