const-tommy.dev
기록을 불러오는 중입니다
supabase.from('products').select() 같은 호출이 클라이언트에서 바로 나간다.permission denied)anon: 익명(비로그인)authenticated: 로그인 사용자service_role: 모든 정책을 무시하는 관리자 (서버에서 secret 키로만 사용)-- products: 익명 손님도 상품 조회는 허용
alter table products enable row level security;
create policy "anyone can read products"
on products for select
to anon
using (true);
-- insights: 로그인 사용자가 '자기 소유 행'만 조회 (행 단위 격리)
alter table insights enable row level security;
create policy "owner reads own insights"
on
using (auth.uid() = owner_id)가 행 단위 격리의 핵심. 사장님 A는 자기 분석만 보고, 사장님 B의 행은 같은 쿼리를 날려도 결과에서 빠진다.using과 with check의 차이는?
A. using은 읽기/대상 행 선별(select·update·delete 시 어떤 행이 보이나), with check는 쓰기 시 검증(insert·update할 값이 조건을 만족하나). insert 정책엔 보통 with check를 쓴다.