Open3
Supabase で anon の全権を奪った後、選択的に権限を付与する
@suin さんのスクラップに記載のSQLを実行すると、テーブルで RLS を適切に設定していても、anon が SELECT すらできなくなる
上記の事象を回避するために、grant
でテーブルごとに権限を付与する。
alter table profiles enable row level security;
create policy "Public profiles are viewable by everyone."
on profiles for select using ( true );
-- 選択的に権限を追加
grant select on profiles to "anon";
これで RLS の設定ミスによるセキュリティインシデントの発生パターンを減らせる。
anon には SELECT 権限与えられていないことを確認できた
SQL は以下
select grantee, table_name, privilege_type
from information_schema.role_table_grants
where table_schema = 'public' order by grantee, table_name, privilege_type;