15 lines
1.0 KiB
SQL
15 lines
1.0 KiB
SQL
-- 1. Ativar Row Level Security nas tabelas principais
|
|
ALTER TABLE steelbook.projetos ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE steelbook.templates_customizados ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE steelbook.t_topicos ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- 2. Criar políticas para permitir apenas usuários autenticados (authenticated)
|
|
-- DROP POLICY IF EXISTS "Autenticados podem gerenciar projetos" ON steelbook.projetos;
|
|
-- CREATE POLICY "Autenticados podem gerenciar projetos" ON steelbook.projetos
|
|
-- FOR ALL USING (auth.role() = 'authenticated');
|
|
|
|
-- Em vez de FOR ALL, para produção rigorosa pode-se dividir, mas como o app depende do uso direto via painel admin, "ALL" para role authenticated é o mínimo viável seguro hoje.
|
|
CREATE POLICY "RLS_Projetos_Auth" ON steelbook.projetos FOR ALL USING (auth.role() = 'authenticated');
|
|
CREATE POLICY "RLS_Templates_Auth" ON steelbook.templates_customizados FOR ALL USING (auth.role() = 'authenticated');
|
|
CREATE POLICY "RLS_Topicos_Auth" ON steelbook.t_topicos FOR ALL USING (auth.role() = 'authenticated');
|