Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE OR REPLACE FUNCTION public.my_user_accounts() RETURNS SETOF UUID
STABLE SECURITY DEFINER
SET search_path = ''
LANGUAGE sql
AS $$
SELECT auth.uid() WHERE auth.uid() IS NOT NULL UNION
SELECT '00000000-0000-0000-0000-000000000000'::uuid UNION
SELECT group_id FROM public.group_membership
WHERE member_id = auth.uid();
$$;


GRANT SELECT ON TABLE public."ResourceAccess" TO anon;
GRANT SELECT ON TABLE public."Document" TO anon;
GRANT SELECT ON TABLE public."Content" TO anon;
GRANT SELECT ON TABLE public."Concept" TO anon;
Comment thread
maparent marked this conversation as resolved.

INSERT INTO auth.users (instance_id, id, aud, role, created_at, updated_at, is_super_admin, is_anonymous)
VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', 'anon', 'anon', now(), now(), false, true);
5 changes: 5 additions & 0 deletions packages/database/supabase/schemas/account.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- Anonymous pseudo-user
INSERT INTO auth.users (instance_id, id, aud, role, created_at, updated_at, is_super_admin, is_anonymous)
VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', 'anon', 'anon', now(), now(), false, true);

CREATE TYPE public."AgentType" AS ENUM (
'person',
'organization',
Expand Down Expand Up @@ -219,6 +223,7 @@ SET search_path = ''
LANGUAGE sql
AS $$
SELECT auth.uid() WHERE auth.uid() IS NOT NULL UNION
SELECT '00000000-0000-0000-0000-000000000000'::uuid UNION
SELECT group_id FROM public.group_membership
WHERE member_id = auth.uid();
$$;
Expand Down
1 change: 1 addition & 0 deletions packages/database/supabase/schemas/concept.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ADD CONSTRAINT "Concept_space_id_fkey" FOREIGN KEY (


REVOKE ALL ON TABLE public."Concept" FROM anon;
GRANT SELECT ON TABLE public."Concept" TO anon;
GRANT ALL ON TABLE public."Concept" TO authenticated;
GRANT ALL ON TABLE public."Concept" TO service_role;

Expand Down
3 changes: 3 additions & 0 deletions packages/database/supabase/schemas/content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ CREATE INDEX resource_access_content_local_id_idx ON public."ResourceAccess" (so
GRANT ALL ON TABLE public."ResourceAccess" TO authenticated;
GRANT ALL ON TABLE public."ResourceAccess" TO service_role;
REVOKE ALL ON TABLE public."ResourceAccess" FROM anon;
GRANT SELECT ON TABLE public."ResourceAccess" TO anon;

REVOKE ALL ON TABLE public."Document" FROM anon;
GRANT SELECT ON TABLE public."Document" TO anon;
GRANT ALL ON TABLE public."Document" TO authenticated;
GRANT ALL ON TABLE public."Document" TO service_role;

REVOKE ALL ON TABLE public."Content" FROM anon;
GRANT SELECT ON TABLE public."Content" TO anon;
GRANT ALL ON TABLE public."Content" TO authenticated;
GRANT ALL ON TABLE public."Content" TO service_role;

Expand Down