Skip to content

Commit a7d94e2

Browse files
fix(alertzero): serialize manage_proposals check through actions.api.get for API-key credentials
1 parent ea8978e commit a7d94e2

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

x-pack/platform/plugins/shared/agentic_investigations/server/proposals/step_types/assert_manage_proposals.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export const assertManageProposals = async ({
3939
try {
4040
const checkPrivileges = security.authz.checkPrivilegesWithRequest(request);
4141
const privileges = await checkPrivileges.atSpace(spaceId, {
42-
kibana: [PROPOSALS_API_PRIVILEGE_MANAGE],
42+
// The serialized form of a feature API privilege is prefixed (see
43+
// api_authorization.ts: requestedPrivileges.map(p => actions.api.get(p)));
44+
// checking the bare string never matches for API-key credentials.
45+
kibana: [security.authz.actions.api.get(PROPOSALS_API_PRIVILEGE_MANAGE)],
4346
});
4447
if (!privileges.hasAllRequested) {
4548
throw new ProposalsAuthorizationError(

x-pack/platform/plugins/shared/agentic_investigations/server/proposals/step_types/step_types.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const FAKE_REQUEST = { fake: true } as never;
2424
const createSecurity = (hasAllRequested: boolean) =>
2525
({
2626
authz: {
27+
// Mirrors the real serializer: feature API privileges are stored in
28+
// prefixed form (api_authorization.ts routes requests through
29+
// actions.api.get). A gate passing the bare string passes unit tests
30+
// with a naive mock but denies every real API-key caller.
31+
actions: { api: { get: (privilege: string) => `api:${privilege}` } },
2732
checkPrivilegesWithRequest: jest.fn().mockReturnValue({
2833
atSpace: jest.fn().mockResolvedValue({ hasAllRequested }),
2934
}),

0 commit comments

Comments
 (0)