Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 493

implementing RLS policy based on criteria (country, organization) in users table

$
0
0

I am creating a web-based regional groundwater information system where information and users are from different countries. While anyone can look at the data, the system should only allow those users from authorized organizations to modify records of wells that are in the same country as the user and associated organization

I have created parent roles ("groups") for each country edit group, and previous logic assigns users to the appropriate group, or leaves them as public.Then, I had to add a country column to all tables where we want this policy to apply, and use something like the following.

CREATE POLICY user_sel_policy ON tablename    FOR SELECT    USING (true);CREATE POLICY user_mod_policy ON tablename TO country_edit_group    USING (country = (SELECT country from users WHERE username = current_user));

This would enable all users to select, but only those in the proper country edit group to modify records.is there a better approach than adding a country column to every table?


Viewing all articles
Browse latest Browse all 493

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>