This repository was archived by the owner on Nov 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
functions/subscribe-newsletter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,8 +254,7 @@ const handler = async (req: Request): Promise<Response> => {
254254 console . error ( "Error in subscribe-newsletter function:" , error ) ;
255255 return new Response (
256256 JSON . stringify ( {
257- error : "Failed to subscribe to newsletter" ,
258- details : error . message
257+ error : "Failed to subscribe to newsletter"
259258 } ) ,
260259 {
261260 status : 500 ,
Original file line number Diff line number Diff line change 1+ -- Security hardening migration: enforce RLS and restrict analytics views
2+
3+ -- 1) Ensure RLS is enabled on sensitive tables (idempotent)
4+ ALTER TABLE public .newsletter_subscribers ENABLE ROW LEVEL SECURITY;
5+ ALTER TABLE public .contact_submissions ENABLE ROW LEVEL SECURITY;
6+ ALTER TABLE public .security_events ENABLE ROW LEVEL SECURITY;
7+ ALTER TABLE public .analytics_daily ENABLE ROW LEVEL SECURITY;
8+ ALTER TABLE public .analytics_page_visits ENABLE ROW LEVEL SECURITY;
9+
10+ -- 2) Remove any legacy permissive public read policies on analytics base tables
11+ DROP POLICY IF EXISTS " Allow public read access for analytics_daily" ON public .analytics_daily ;
12+ DROP POLICY IF EXISTS " Allow public read access for analytics_page_visits" ON public .analytics_page_visits ;
13+
14+ -- 3) Restrict direct access to analytics views
15+ REVOKE SELECT ON TABLE public .analytics_public FROM anon, authenticated;
16+ REVOKE SELECT ON TABLE public .analytics_summary FROM anon, authenticated;
17+ REVOKE SELECT ON TABLE public .analytics_public FROM PUBLIC;
18+ REVOKE SELECT ON TABLE public .analytics_summary FROM PUBLIC;
19+
20+ -- 4) Ensure execute access on controlled SECURITY DEFINER functions for aggregated analytics
21+ GRANT EXECUTE ON FUNCTION public .get_analytics_daily (date , date ) TO public;
22+ GRANT EXECUTE ON FUNCTION public .get_analytics_page_visits (date , date ) TO public;
You can’t perform that action at this time.
0 commit comments