Unauthorized route migration for routes owned by stack-monitoring (#198372)

### Authz API migration for unauthorized routes

This PR migrates unauthorized routes owned by your team to a new
security configuration.
Please refer to the documentation for more information: [Authorization
API](https://docs.elastic.dev/kibana-dev-docs/key-concepts/security-api-authorization)

### **Before migration:**
```ts
router.get({
  path: '/api/path',
  ...
}, handler);
```

### **After migration:**
```ts
router.get({
  path: '/api/path',
  security: {
    authz: {
      enabled: false,
      reason: 'This route is opted out from authorization because ...',
    },
  },
  ...
}, handler);
```

### What to do next?
1. Review the changes in this PR.
2. Elaborate on the reasoning to opt-out of authorization.
3. Routes without a compelling reason to opt-out of authorization should
plan to introduce them as soon as possible.
2. You might need to update your tests to reflect the new security
configuration:
  - If you have snapshot tests that include the route definition.

## Any questions?
If you have any questions or need help with API authorization, please
reach out to the `@elastic/kibana-security` team.

---------

Co-authored-by: consulthys <valentin.crettaz@consulthys.com>
This commit is contained in:
Kibana Machine 2024-12-27 23:08:10 +11:00 committed by GitHub
parent 9865da3844
commit 03999da148
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View file

@ -36,6 +36,13 @@ export function registerDynamicRoute({
router.get(
{
path: `${MONITORING_COLLECTION_BASE_PATH}/{type}`,
security: {
authz: {
enabled: false,
reason:
'This route is opted out from authorization because it is only retrieving the ES cluster UUID',
},
},
options: {
access: 'internal',
authRequired: true,

View file

@ -20,6 +20,13 @@ export function registerV1PrometheusRoute({
router.get(
{
path: PROMETHEUS_PATH,
security: {
authz: {
enabled: false,
reason:
'This route is opted out from authorization because it is not interacting with ES at all',
},
},
options: {
authRequired: true,
tags: ['api'], // ensures that unauthenticated calls receive a 401 rather than a 302 redirect to login page