[Infra] Update deprecated access tags to the new security configuration in routes (#204214)

## Summary

Closes https://github.com/elastic/kibana/issues/203793

This PR replaces the deprecated `access` tags with the new `security`
configuration.

All instances of `options: {tags: ['access:infra']}` are now updated to
`security: {authz: {requiredPrivileges: ['infra']}}`.
This commit is contained in:
Irene Blanco 2024-12-16 11:02:04 +01:00 committed by GitHub
parent 50713ca6d8
commit 73066e8cc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,9 +52,8 @@ export class KibanaFramework {
config: InfraRouteConfig<Params, Query, Body, Method>,
handler: RequestHandler<Params, Query, Body, InfraPluginRequestHandlerContext>
) {
const defaultOptions = {
tags: ['access:infra'],
};
const defaultSecurity = { authz: { requiredPrivileges: ['infra'] } };
const routeConfig = {
path: config.path,
validate: config.validate,
@ -65,7 +64,8 @@ export class KibanaFramework {
* using `as ...` below to ensure the route config has
* the correct options type.
*/
options: { ...config.options, ...defaultOptions },
options: { ...config.options },
security: defaultSecurity,
};
switch (config.method) {
case 'get':
@ -89,15 +89,12 @@ export class KibanaFramework {
public registerVersionedRoute<Method extends RouteMethod = any>(
config: InfraVersionedRouteConfig<Method>
) {
const defaultOptions = {
tags: ['access:infra'],
};
const defaultSecurity = { authz: { requiredPrivileges: ['infra'] } };
const routeConfig = {
access: config.access,
path: config.path,
// Currently we have no use of custom options beyond tags, this can be extended
// beyond defaultOptions if it's needed.
options: defaultOptions,
security: defaultSecurity,
};
switch (config.method) {
case 'get':