Fix security vulnerability

This commit is contained in:
gpt-engineer-app[bot]
2025-10-26 15:04:32 +00:00
parent f4bd44e638
commit f9228d5024
2 changed files with 50 additions and 1 deletions

View File

@ -40,7 +40,27 @@ export type Database = {
} }
} }
Views: { Views: {
[_ in never]: never petition_signatures_public: {
Row: {
comment: string | null
created_at: string | null
id: string | null
name: string | null
}
Insert: {
comment?: string | null
created_at?: string | null
id?: string | null
name?: string | null
}
Update: {
comment?: string | null
created_at?: string | null
id?: string | null
name?: string | null
}
Relationships: []
}
} }
Functions: { Functions: {
[_ in never]: never [_ in never]: never

View File

@ -0,0 +1,29 @@
-- Create a public view that excludes email addresses
CREATE OR REPLACE VIEW public.petition_signatures_public AS
SELECT
id,
created_at,
name,
comment
FROM public.petition_signatures;
-- Drop existing permissive policies
DROP POLICY IF EXISTS "Anyone can view signatures" ON public.petition_signatures;
DROP POLICY IF EXISTS "Anyone can sign the petition" ON public.petition_signatures;
-- Restrict direct table access - only authenticated users can view full data
CREATE POLICY "Only authenticated users can view all signature data"
ON public.petition_signatures
FOR SELECT
TO authenticated
USING (true);
-- Allow anyone to insert (it's a petition, people need to sign it)
CREATE POLICY "Anyone can sign the petition"
ON public.petition_signatures
FOR INSERT
TO anon, authenticated
WITH CHECK (true);
-- Grant SELECT on the public view to everyone (including anonymous)
GRANT SELECT ON public.petition_signatures_public TO anon, authenticated;