24. ● ②テーブルごとにアクセス制限するPolicyの設定
● ①テーブルごとにRow Level Securityを有効化
ALTER TABLE tenants ENABLE ROW LEVEL SECURITY;
やってみた:RLS設定のクエリ
24
create role appuser login password 'xxxxxxx';
alter default privileges for role appuser in schema public
grant select, insert, update, delete on tables to appuser;
CREATE POLICY tenant_isolation_policy ON tenants
USING (tenant_id = current_setting('app.current_tenant'));
● ③ロールの作成
アプリケーションからは権限の弱いロールでアクセスさせる
(AppendixにRole設定時の注意あり)