Skip to content

Commit

Permalink
[8.x] Authorized route migration for routes owned by @elastic/kibana-…
Browse files Browse the repository at this point in the history
…core (elastic#198187) (elastic#199489)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Authorized route migration for routes owned by @elastic/kibana-core
(elastic#198187)](elastic#198187)

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

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

<!--BACKPORT [{"author":{"name":"Kibana
Machine","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-08T00:48:30Z","message":"Authorized
route migration for routes owned by @elastic/kibana-core
(elastic#198187)\n\nCo-authored-by: Alejandro Fernández Haro
<[email protected]>","sha":"543cc2f494e11d50685ff07afeca49f45008ecdd","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","enhancement","release_note:skip","Feature:Security/Authorization","v9.0.0","Team:Cloud
Security","backport:prev-minor","Authz: API
migration"],"title":"Authorized route migration for routes owned by
@elastic/kibana-core","number":198187,"url":"https://github.com/elastic/kibana/pull/198187","mergeCommit":{"message":"Authorized
route migration for routes owned by @elastic/kibana-core
(elastic#198187)\n\nCo-authored-by: Alejandro Fernández Haro
<[email protected]>","sha":"543cc2f494e11d50685ff07afeca49f45008ecdd"}},"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/198187","number":198187,"mergeCommit":{"message":"Authorized
route migration for routes owned by @elastic/kibana-core
(elastic#198187)\n\nCo-authored-by: Alejandro Fernández Haro
<[email protected]>","sha":"543cc2f494e11d50685ff07afeca49f45008ecdd"}}]}]
BACKPORT-->
  • Loading branch information
kibanamachine authored Nov 8, 2024
1 parent 4b4bd24 commit b667b5a
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 b667b5a

Please sign in to comment.