Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: rls policy on user not respecting the API key
Brad Barbin06052312a571
diff --git a/packages/database/supabase/migrations/20251023192635_query-users-with-api-key.sql b/packages/database/supabase/migrations/20251023192635_query-users-with-api-key.sqlnew file mode 100644index 0000000000..f9dff7732f--- /dev/null+++ b/packages/database/supabase/migrations/20251023192635_query-users-with-api-key.sql@@ -0,0 +1,20 @@+ALTER POLICY "Users can view other users from their same company" ON "user" USING (+ "id" IN (+ SELECT "userId"+ FROM "userToCompany"+ WHERE "companyId" = ANY (+ (+ SELECT get_companies_with_employee_role()+ )::text[]+ )+ )+);++ALTER POLICY "Authenticated users can view userToCompany" ON "userToCompany"+ USING (+ "companyId" = ANY (+ (+ SELECT get_companies_with_employee_role()+ )::text[]+ )+ );\ No newline at end of filediff --git a/scripts/sandbox.ts b/scripts/sandbox.tsindex 29ba8ad43f..f336f35e88 100644--- a/scripts/sandbox.ts+++ b/scripts/sandbox.ts@@ -5,21 +5,18 @@ config();const carbon = createClient(process.env.SUPABASE_URL!,- process.env.SUPABASE_SERVICE_ROLE_KEY!+ process.env.SUPABASE_ANON_KEY!,+ {+ global: {+ headers: {+ "carbon-key": "crbn_**************",+ },+ },+ });-const companyId = "fkeqqGSn7VGrHtjk8LVFz";-(async () => {- const holidays = await carbon- .from("holiday")- .select("*")- .eq("companyId", companyId)- .gte("date", new Date().toISOString())- .lte(- "date",- new Date(new Date().setDate(new Date().getDate() + 30)).toISOString()- );+ const employees = await carbon.from("employees").select("*").limit(1000);- console.log(holidays);+ console.log(employees);})();