-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: row level security on config_items & components
- Loading branch information
1 parent
fbf1801
commit 08fde2d
Showing
4 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ALTER TABLE config_items ENABLE ROW LEVEL SECURITY; | ||
|
||
ALTER TABLE components ENABLE ROW LEVEL SECURITY; | ||
|
||
-- POLICIES | ||
DROP POLICY IF EXISTS config_items_auth ON config_items; | ||
|
||
CREATE POLICY config_items_auth ON config_items | ||
FOR ALL TO postgrest_api, postgrest_anon | ||
USING (tags::jsonb @> (current_setting('request.jwt.claims', TRUE)::json ->> 'tags')::jsonb | ||
OR current_setting('request.jwt.claims', TRUE)::json ->> 'agent_id' = agent_id::text); | ||
|
||
DROP POLICY IF EXISTS components_auth ON components; | ||
|
||
CREATE POLICY components_auth ON components | ||
FOR ALL TO postgrest_api, postgrest_anon | ||
USING (current_setting('request.jwt.claims', TRUE)::json ->> 'agent_id' = agent_id::text); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ALTER TABLE config_items DISABLE ROW LEVEL SECURITY; | ||
|
||
ALTER TABLE components DISABLE ROW LEVEL SECURITY; | ||
|
||
-- POLICIES | ||
DROP POLICY IF EXISTS config_items_auth ON config_items; | ||
|
||
DROP POLICY IF EXISTS components_auth ON components; |