-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathcreate_policy.sql
More file actions
28 lines (22 loc) · 908 Bytes
/
create_policy.sql
File metadata and controls
28 lines (22 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
CREATE POLICY user_policy ON users FOR ALL TO authenticated_users USING (user_id = current_user_id());
CREATE POLICY admin_policy ON sensitive_data
AS RESTRICTIVE
FOR SELECT
TO admin_role
USING (department = current_user_department())
WITH CHECK (approved = true);
CREATE POLICY complex_policy ON documents
FOR UPDATE
TO document_editors
USING (
owner_id = current_user_id() OR
(shared = true AND permissions @> '{"edit": true}')
)
WITH CHECK (
status != 'archived' AND
last_modified > now() - interval '1 day'
);
CREATE POLICY simple_policy ON posts FOR SELECT TO public USING (published = true);
CREATE POLICY "simple_policy" ON posts FOR SELECT TO public USING (published = true);
CREATE POLICY "Simple Policy" ON posts FOR SELECT TO public USING (published = true);
CREATE POLICY SimplePolicy ON posts FOR SELECT TO public USING (published = true);