Skip to content

Commit 991759e

Browse files
guguclaude
andcommitted
Use like operator for wildcard table resource in cedar policy
- Generate `resource like RocketAdmin::Table::"connId/*"` instead of `==` - Update parser to recognize both `==` and `like` for resource matching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ddf75d commit 991759e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

frontend/src/app/lib/cedar-policy-items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function policyItemsToCedarPolicy(items: CedarPolicyItem[], connectionId:
9393

9494
if (item.action.startsWith('table:')) {
9595
if (item.tableName === '*') {
96-
resource = `resource == RocketAdmin::Table::"${connectionId}/*"`;
96+
resource = `resource like RocketAdmin::Table::"${connectionId}/*"`;
9797
} else {
9898
resource = `resource == RocketAdmin::Table::"${connectionId}/${item.tableName}"`;
9999
}

frontend/src/app/lib/cedar-policy-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function parsePermitBody(body: string): ParsedPermitStatement {
186186
}
187187
}
188188

189-
const resourceMatch = body.match(/resource\s*==\s*(RocketAdmin::\w+)::"([^"]+)"/);
189+
const resourceMatch = body.match(/resource\s*(?:==|like)\s*(RocketAdmin::\w+)::"([^"]+)"/);
190190
if (resourceMatch) {
191191
result.resourceType = resourceMatch[1];
192192
result.resourceId = resourceMatch[2];

0 commit comments

Comments
 (0)