Skip to content

Commit

Permalink
fix(RLS): more secure
Browse files Browse the repository at this point in the history
  • Loading branch information
LeGmask committed Nov 14, 2023
1 parent 0373cbb commit ed8e2bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CREATE EXTENSION IF NOT EXISTS "pgsodium" WITH SCHEMA "pgsodium";
-- *not* creating schema, since initdb creates it


ALTER SCHEMA "public" OWNER TO "postgres";
-- ALTER SCHEMA "public" OWNER TO "postgres";

--
-- Name: pg_graphql; Type: EXTENSION; Schema: -; Owner: -
Expand Down Expand Up @@ -118,7 +118,7 @@ CREATE FUNCTION "public"."get_professors_ranking"("param_user_id" "uuid" DEFAULT
end;$$;


ALTER FUNCTION "public"."get_professors_ranking"("param_user_id" "uuid") OWNER TO "postgres";
-- ALTER FUNCTION "public"."get_professors_ranking"("param_user_id" "uuid") OWNER TO "postgres";

--
-- Name: handle_new_user(); Type: FUNCTION; Schema: public; Owner: postgres
Expand Down Expand Up @@ -159,8 +159,6 @@ END;
$$;


ALTER FUNCTION "public"."trigger_set_timestamp"() OWNER TO "supabase_admin";

--
-- Name: fr; Type: TEXT SEARCH CONFIGURATION; Schema: public; Owner: postgres
--
Expand Down
29 changes: 29 additions & 0 deletions supabase/migrations/20231114082321_addRLS.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- add rls for godparents
create policy "godparents publicly visible" on "public"."godparents" for all using (true) with check (true);
create policy "user can edit godparents" on "public"."godparents" for update using (auth.uid() = "user_id");
alter table "public"."godparents" enable row level security;

-- add rls for memberships
create policy "memberships is restricted to user" on "public"."memberships" for all using (auth.uid() = "user_id");
alter table "public"."memberships" enable row level security;

-- add rls for migrations
create policy "migrations is private" on "public"."migrations" for all using (false);

-- add rls for professors
create policy "professors is visible to authenticated users" on "public"."professors" for all using (auth.uid() is not null);
create policy "professors isn't editable" on "public"."professors" for update using (false);
alter table "public"."professors" enable row level security;

-- add rls for professors_ranking
create policy "professors_ranking is visible to authenticated users" on "public"."professors_ranking" for all using (auth.uid() is not null);
create policy "professors_ranking is modifiable by owner" on "public"."professors_ranking" for update using (auth.uid() = "user_id");
alter table "public"."professors_ranking" enable row level security;

-- add rls for promos
drop policy if exists "Promos are viewable by everyone." on "public"."promos";
create policy "promos is readable by everyone" on "public"."promos" for all using (true);
create policy "promos isn't editable" on "public"."promos" for update using (false);
alter table "public"."promos" enable row level security;


1 comment on commit ed8e2bb

@vercel
Copy link

@vercel vercel bot commented on ed8e2bb Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.