Skip to content

Commit

Permalink
[8.x] Unauthorized route migration for routes owned by kibana-cloud-s…
Browse files Browse the repository at this point in the history
…ecurity-posture (#198353) (#200282)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Unauthorized route migration for routes owned by
kibana-cloud-security-posture
(#198353)](#198353)

<!--- 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-14T23:50:01Z","message":"Unauthorized
route migration for routes owned by kibana-cloud-security-posture
(#198353)\n\n### Authz API migration for unauthorized routes\r\n\r\nThis
PR migrates unauthorized routes owned by your team to a new\r\nsecurity
configuration.\r\nPlease refer to the documentation for more
information:
[Authorization\r\nAPI](https://docs.elastic.dev/kibana-dev-docs/key-concepts/security-api-authorization)\r\n\r\n###
**Before migration:**\r\n```ts\r\nrouter.get({\r\n path:
'/api/path',\r\n ...\r\n}, handler);\r\n```\r\n\r\n### **After
migration:**\r\n```ts\r\nrouter.get({\r\n path: '/api/path',\r\n
security: {\r\n authz: {\r\n enabled: false,\r\n reason: 'This route is
opted out from authorization because ...',\r\n },\r\n },\r\n ...\r\n},
handler);\r\n```\r\n\r\n### What to do next?\r\n1. Review the changes in
this PR.\r\n2. Elaborate on the reasoning to opt-out of
authorization.\r\n3. Routes without a compelling reason to opt-out of
authorization should\r\nplan to introduce them as soon as
possible.\r\n2. You might need to update your tests to reflect the new
security\r\nconfiguration:\r\n - If you have snapshot tests that include
the route definition.\r\n\r\n## Any questions?\r\nIf you have any
questions or need help with API authorization, please\r\nreach out to
the `@elastic/kibana-security`
team.\r\n\r\n---------\r\n\r\nCo-authored-by: Paulo Silva
<[email protected]>","sha":"767a4bbd406bb5d87ca39d1b9a474820343147bb","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","release_note:skip","Feature:Security/Authorization","v9.0.0","Team:Cloud
Security","backport:prev-minor","Authz: API
migration"],"title":"Unauthorized route migration for routes owned by
kibana-cloud-security-posture","number":198353,"url":"https://github.com/elastic/kibana/pull/198353","mergeCommit":{"message":"Unauthorized
route migration for routes owned by kibana-cloud-security-posture
(#198353)\n\n### Authz API migration for unauthorized routes\r\n\r\nThis
PR migrates unauthorized routes owned by your team to a new\r\nsecurity
configuration.\r\nPlease refer to the documentation for more
information:
[Authorization\r\nAPI](https://docs.elastic.dev/kibana-dev-docs/key-concepts/security-api-authorization)\r\n\r\n###
**Before migration:**\r\n```ts\r\nrouter.get({\r\n path:
'/api/path',\r\n ...\r\n}, handler);\r\n```\r\n\r\n### **After
migration:**\r\n```ts\r\nrouter.get({\r\n path: '/api/path',\r\n
security: {\r\n authz: {\r\n enabled: false,\r\n reason: 'This route is
opted out from authorization because ...',\r\n },\r\n },\r\n ...\r\n},
handler);\r\n```\r\n\r\n### What to do next?\r\n1. Review the changes in
this PR.\r\n2. Elaborate on the reasoning to opt-out of
authorization.\r\n3. Routes without a compelling reason to opt-out of
authorization should\r\nplan to introduce them as soon as
possible.\r\n2. You might need to update your tests to reflect the new
security\r\nconfiguration:\r\n - If you have snapshot tests that include
the route definition.\r\n\r\n## Any questions?\r\nIf you have any
questions or need help with API authorization, please\r\nreach out to
the `@elastic/kibana-security`
team.\r\n\r\n---------\r\n\r\nCo-authored-by: Paulo Silva
<[email protected]>","sha":"767a4bbd406bb5d87ca39d1b9a474820343147bb"}},"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/198353","number":198353,"mergeCommit":{"message":"Unauthorized
route migration for routes owned by kibana-cloud-security-posture
(#198353)\n\n### Authz API migration for unauthorized routes\r\n\r\nThis
PR migrates unauthorized routes owned by your team to a new\r\nsecurity
configuration.\r\nPlease refer to the documentation for more
information:
[Authorization\r\nAPI](https://docs.elastic.dev/kibana-dev-docs/key-concepts/security-api-authorization)\r\n\r\n###
**Before migration:**\r\n```ts\r\nrouter.get({\r\n path:
'/api/path',\r\n ...\r\n}, handler);\r\n```\r\n\r\n### **After
migration:**\r\n```ts\r\nrouter.get({\r\n path: '/api/path',\r\n
security: {\r\n authz: {\r\n enabled: false,\r\n reason: 'This route is
opted out from authorization because ...',\r\n },\r\n },\r\n ...\r\n},
handler);\r\n```\r\n\r\n### What to do next?\r\n1. Review the changes in
this PR.\r\n2. Elaborate on the reasoning to opt-out of
authorization.\r\n3. Routes without a compelling reason to opt-out of
authorization should\r\nplan to introduce them as soon as
possible.\r\n2. You might need to update your tests to reflect the new
security\r\nconfiguration:\r\n - If you have snapshot tests that include
the route definition.\r\n\r\n## Any questions?\r\nIf you have any
questions or need help with API authorization, please\r\nreach out to
the `@elastic/kibana-security`
team.\r\n\r\n---------\r\n\r\nCo-authored-by: Paulo Silva
<[email protected]>","sha":"767a4bbd406bb5d87ca39d1b9a474820343147bb"}}]}]
BACKPORT-->
  • Loading branch information
kibanamachine authored Nov 15, 2024
1 parent 5bd6bce commit 5cd7cce
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions x-pack/plugins/kubernetes_security/server/routes/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export const registerAggregateRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/kubernetes_security/server/routes/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export const registerCountRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const registerMultiTermsAggregateRoute = (router: IRouter, logger: Logger
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export const registerAlertStatusRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/session_view/server/routes/alerts_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const registerAlertsRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
requiredPrivileges: ['securitySolution'],
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export const registerGetTotalIOBytesRoute = (router: IRouter, logger: Logger) =>
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/session_view/server/routes/io_events_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export const registerIOEventsRoute = (router: IRouter, logger: Logger) => {
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const registerProcessEventsRoute = (
.addVersion(
{
version: '1',
security: {
authz: {
enabled: false,
reason: `This route delegates authorization to Elasticsearch and it's not tied to a Kibana privilege.`,
},
},
validate: {
request: {
query: schema.object({
Expand Down

0 comments on commit 5cd7cce

Please sign in to comment.