Replies: 5 comments
-
I also just tried this which seems intuitive:
But it fails with this error:
Is it possible that a policy based on a non-primary key (i.e. |
Beta Was this translation helpful? Give feedback.
-
Just glancing at this. What is your select policy? That has to be met also for update. |
Beta Was this translation helpful? Give feedback.
-
Thanks for peeking at this, @GaryAustin1. For now, my SELECT policy is set to (Not that I have renamed I wish there were a way to see what was being fed into and coming out of these policy queries. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Your policy looks very similar to this: |
Beta Was this translation helpful? Give feedback.
-
Yep... That was the issue, @GaryAustin1! ❤️ I spent too many hours on this. |
Beta Was this translation helpful? Give feedback.
-
In my application, a user logs game stats by updating records in a
points
table. Thepoints
records include ateam_id
.I'd like a
user_team
table to resolve permissions for a user (who is already in theauth
table) to edit point-records based on theteam_id
. (The idea is to manage access for one user to multiple teams by creating several linking records in theuser_team
table.)points
: many game-tracking columns +id
(unique key) andteam_id
user_team
:user_id
(uuid matchingauth
table),team_id
andemail
(matchingauth
table)TLDR; does the user with auth.uid() have permission to UPDATE a point with
team_id
based onuser_team
?I can't seem to create an RLS policy to enforce this paradigm.
Currently, I'm trying USING expression
true
...and WITH CHECK expression set to:
The intent is that the
points
->team_id
value in the app's UPDATE request would fillpoints.team_id
in the policy check's WHERE clause. I can't find much help content on policies built on outside tables (likeuser_team
… rather than the table being updated) and driven by non primary keys (e.g.points.team_id
instead ofpoints.id
).Are there tricks for debugging RLS policies? When the permissions don't work, the process is a black box.
Thanks for your help.
P.S. Functionally, this request is the same as this StackOverflow query, but I haven't been able to turn the responses into a functional solution.
P.P.S. For extra credit, I'd love to use
user_team.email
values (presumably throughauth.jwt()
) instead ofuser_id
but the former feels like a more direct and literal first test.Beta Was this translation helpful? Give feedback.
All reactions