diff schema/updates/1424/01.add_axis_rls.sql @ 5013:7dff1015283d

Add row level security policies for waterway axis Enforcing the area of responsibility this way instead of leaving it up to the importer implementation will also reduce complexity of statements needed to implement keeping of historic axis data.
author Tom Gottfried <tom@intevation.de>
date Thu, 12 Mar 2020 14:49:19 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/updates/1424/01.add_axis_rls.sql	Thu Mar 12 14:49:19 2020 +0100
@@ -0,0 +1,16 @@
+CREATE POLICY hide_nothing ON waterway.waterway_axis
+    FOR SELECT TO waterway_user USING (true);
+CREATE POLICY sys_admin ON waterway.waterway_axis
+    FOR ALL TO sys_admin USING (true);
+
+CREATE POLICY responsibility_area_insert ON waterway.waterway_axis
+    FOR INSERT TO waterway_admin
+    WITH CHECK (users.utm_covers(wtwaxs));
+CREATE POLICY responsibility_area_update ON waterway.waterway_axis
+    FOR UPDATE TO waterway_admin
+    USING (users.utm_covers(wtwaxs));
+CREATE POLICY responsibility_area_delete ON waterway.waterway_axis
+    FOR DELETE TO waterway_admin
+    USING (users.utm_covers(wtwaxs));
+
+ALTER TABLE waterway.waterway_axis ENABLE ROW LEVEL SECURITY;