Skip to content

Commit

Permalink
Unauthorized route migration for routes owned by fleet (elastic#198330)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Dec 18, 2024
1 parent 0aa45fc commit 5103345
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/plugins/custom_integrations/server/routes/define_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function defineRoutes(
{
path: ROUTES_APPEND_CUSTOM_INTEGRATIONS,
validate: false,
security: {
authz: {
requiredPrivileges: ['integrations-read'],
},
},
},
async (context, request, response) => {
const integrations = customIntegrationsRegistry.getAppendCustomIntegrations();
Expand All @@ -35,6 +40,11 @@ export function defineRoutes(
{
path: ROUTES_REPLACEMENT_CUSTOM_INTEGRATIONS,
validate: false,
security: {
authz: {
requiredPrivileges: ['integrations-read'],
},
},
},
async (context, request, response) => {
const integrations = customIntegrationsRegistry.getReplacementCustomIntegrations();
Expand Down
11 changes: 10 additions & 1 deletion x-pack/plugins/fleet/server/services/security/fleet_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type RequestHandler,
type RouteMethod,
} from '@kbn/core/server';
import type { VersionedRouteConfig } from '@kbn/core-http-server';
import type { RouteSecurity, VersionedRouteConfig } from '@kbn/core-http-server';

import { PUBLIC_API_ACCESS } from '../../../common/constants';
import type { FleetRequestHandlerContext } from '../..';
Expand All @@ -35,6 +35,14 @@ import {
doesNotHaveRequiredFleetAuthz,
} from './security';

export const DEFAULT_FLEET_ROUTE_SECURITY: RouteSecurity = {
authz: {
enabled: false,
reason:
'This route is opted out from authorization because Fleet use his own authorization model.',
},
};

function withDefaultPublicAccess<Method extends RouteMethod>(
options: FleetVersionedRouteConfig<Method>
): VersionedRouteConfig<Method> {
Expand All @@ -44,6 +52,7 @@ function withDefaultPublicAccess<Method extends RouteMethod>(
return {
...options,
access: PUBLIC_API_ACCESS,
security: DEFAULT_FLEET_ROUTE_SECURITY,
};
}
}
Expand Down

0 comments on commit 5103345

Please sign in to comment.