Skip to content

Commit

Permalink
Fix migration sql
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Oct 11, 2023
1 parent 314c89f commit f1d1a3b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/web/migrations/2023-01-06_rls.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CREATE POLICY "connection_creator_access" ON "public"."pipeline"

-- Contains secrets that shouldn't be publicly available
ALTER TABLE "public"."integration" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "public"."migrations" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "public"."_migrations" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "public"."institution" ENABLE ROW LEVEL SECURITY;
-- Should this be allowed?
CREATE POLICY "public_readable" ON public.institution FOR SELECT USING (true);
Expand Down
8 changes: 4 additions & 4 deletions apps/web/migrations/2023-04-02_0140_admin_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ $$;
-- even though empirically it works because this is security we are gonna be more cautious.
-- Will see if the supabase team has any ideas...
-- @see https://usevenice.slack.com/archives/C04NUANB7FW/p1680462683033239
CREATE OR REPLACE FUNCTION auth.is_admin()
RETURNS boolean
LANGUAGE sql
CREATE OR REPLACE FUNCTION auth.is_admin()
RETURNS boolean
LANGUAGE sql
STABLE
AS $function$
select nullif(current_setting('request.jwt.claims', true), '')::jsonb #> '{app_metadata,isAdmin}' = 'true'::jsonb
Expand All @@ -37,7 +37,7 @@ CREATE POLICY "admin_access" ON "public"."integration" USING (auth.is_admin());
CREATE POLICY "admin_access" ON "public"."resource" USING (auth.is_admin());
CREATE POLICY "admin_access" ON "public"."pipeline" USING (auth.is_admin());

CREATE POLICY "admin_access" ON "public"."migrations" USING (auth.is_admin());
CREATE POLICY "admin_access" ON "public"."_migrations" USING (auth.is_admin());

DO $$
BEGIN
Expand Down
2 changes: 1 addition & 1 deletion apps/web/migrations/2023-04-29_1549_multi_tenant.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DROP POLICY IF EXISTS admin_access ON institution;
DROP POLICY IF EXISTS admin_access ON integration;
DROP POLICY IF EXISTS admin_access ON resource;
DROP POLICY IF EXISTS admin_access ON pipeline;
DROP POLICY IF EXISTS admin_access ON migrations;
DROP POLICY IF EXISTS admin_access ON _migrations;

DROP FUNCTION IF EXISTS auth.is_admin;
DROP PROCEDURE IF EXISTS auth.set_user_admin;
Expand Down

0 comments on commit f1d1a3b

Please sign in to comment.