Skip to content

Row level security and views, how to allow different rows to different users? #1750

Discussion options

You must be logged in to vote

Am I missing something here or is there no way to use RLS with views to expose different rows to different users via PostgREST using current_user (which I use because that seems like what all examples use)?

No, you're not missing anything - that's true. If PostgreSQL were to support either RLS directly on views or views with SECURITY INVOKER (or ideally both) that would improve the situation a lot.

Is the idea to use current_setting('request.jwt.claim.role') instead of current_user?

Yes, that's the only real solution right now. Either directly or via helper function as mentioned by Ruslan - doesn't matter much. Still feels a bit like a hack, tbh.

Or is it simply recommended to use ta…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1748 on February 03, 2021 15:26.