Commit 9e04372
committed
Add RLS support and fix permission checks (#2309)
- Previously, age only set ACL_SELECT and ACL_INSERT in RTEPermissionInfo,
bypassing pg's privilege checking for DELETE and UPDATE operations.
- Additionally, RLS policies were not enforced because AGE uses CMD_SELECT
for all Cypher queries, causing the rewriter to skip RLS policy application.
Permission fixes:
- Add ACL_DELETE permission flag for DELETE clause operations
- Add ACL_UPDATE permission flag for SET/REMOVE clause operations
- Recursively search RTEs including subqueries for permission info
RLS support:
- Implemented at executor level because age transforms all cypher
queries to CMD_SELECT, so pg's rewriter never adds RLS
policies for INSERT/UPDATE/DELETE operations. There isnt an
appropriate rewriter hook to modify this behavior, so we do it
in executor instead.
- Add setup_wcos() to apply WITH CHECK policies at execution time
for CREATE, SET, and MERGE operations
- Add setup_security_quals() and check_security_quals() to apply
USING policies for UPDATE and DELETE operations
- USING policies silently filter rows (matching pg behavior)
- WITH CHECK policies raise errors on violation
- DETACH DELETE raises error if edge RLS blocks deletion to prevent
dangling edges
- Add permission checks and rls in startnode/endnode functions
- Add regression tests
Assisted-by AI
Resolved Conflicts:
src/backend/executor/cypher_create.c
src/backend/executor/cypher_delete.c
src/backend/executor/cypher_merge.c
src/backend/executor/cypher_set.c
src/backend/executor/cypher_utils.c1 parent 3656812 commit 9e04372
11 files changed
Lines changed: 4238 additions & 5 deletions
File tree
- regress
- expected
- sql
- src
- backend
- executor
- parser
- utils/adt
- include/executor
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
0 commit comments