You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(db): core.system_config grants nothing to authenticated, so the geographic settings screen 403s on every read #856
Found by the release-1 route sweep (#852, PR #855).
Evidence
core.system_config has RLS off and grants only postgres and service_role:
select grantee||':'||privilege_type from information_schema.role_table_grants
where table_schema='core' and table_name='system_config';
-- postgres:*, service_role:* — nothing for `authenticated`
select relrowsecurity from pg_class where oid='core.system_config'::regclass; -- f
So every logged-in read through PostgREST answers 42501 insufficient privilege. The only caller is apps/scaffald/app/(admin)/office/settings/geographic.tsx:15-20, which reads site_overlap_threshold_percent directly through supabase.schema('core') rather than through the api edge function, and writes it back at :61.
This is the fifth instance of the same defect class — see #481 (8 tables), #751 (20 more), and the core_table_grants_gap pattern. The prepush guard added with #751 checks service_role only, which is why this one survived: the gap here is authenticated.
Change
One idempotent migration granting the right privileges on core.system_config. Decide the shape first: either
GRANT SELECT TO authenticated + GRANT INSERT, UPDATE TO service_role and enable RLS with an office-role read policy, or
leave the table service-role-only and move the screen onto an api endpoint (/v1/office/settings/geographic), which matches how every other office screen reads privileged data.
Recommendation: the second. A settings table that any authenticated user can read is a wider grant than the screen needs — the screen is office-role gated, the table is not — and every other office read already goes through the edge function with requireRole.
Apply to dev/preview/prod via the Management API path, recording the ledger (numeric migrations bypass schema_migrations).
Extend the prepush grants guard to check authenticated reads on tables the client queries directly, so the next one is caught by the guard rather than by a 403 storm.
Acceptance
/office/settings/geographic loads its current threshold and saves a new one, verified in a browser as an office user
Activity
feat(office-settings): read and write the platform settings in core.s…