Skip to content

Commit c1fb4f3

Browse files
committed
feat: enhance action matching in public policy validation for broader compatibility
1 parent 159ba35 commit c1fb4f3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

backend/src/entities/cedar-authorization/cedar-authorization.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,10 @@ export class CedarAuthorizationService implements ICedarAuthorizationService, On
426426
throw new HttpException({ message: Messages.PUBLIC_POLICY_ACTION_NOT_ALLOWED }, HttpStatus.BAD_REQUEST);
427427
}
428428
const allowed = new Set<string>([CedarAction.TableQuery, CedarAction.ColumnRead]);
429-
const actions = [...policyText.matchAll(/action\s*==\s*RocketAdmin::Action::"([^"]+)"/g)].map((m) => m[1]);
429+
// Capture every action literal regardless of the operator used: `action == Action::"x"`,
430+
// `action in [Action::"x", Action::"y"]`, or `action in Action::"x"`. The Action type only
431+
// ever appears in the action clause, so matching it anywhere in the policy text is correct.
432+
const actions = [...policyText.matchAll(/RocketAdmin::Action::"([^"]+)"/g)].map((m) => m[1]);
430433
for (const action of actions) {
431434
if (!allowed.has(action)) {
432435
throw new HttpException({ message: Messages.PUBLIC_POLICY_ACTION_NOT_ALLOWED }, HttpStatus.BAD_REQUEST);

0 commit comments

Comments
 (0)