行级安全性不适用于表所有者

行级安全性不适用于表所有者

本文介绍了行级安全性不适用于表所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表, customer ,在该表上执行了以下操作:

I have a table, customer on which I did the following:

ALTER TABLE customer FORCE ROW LEVEL SECURITY;
CREATE POLICY customer_rls ON  customer USING (false);

但是,仍然执行 SELECT * FROM customer 返回所有行。

However, doing SELECT * FROM customer still returns all the rows.

当前角色是 myrole

\dg myrole
           List of roles
 Role name | Attributes | Member of
-----------+------------+-----------
 my_role   |            | {}

您可以看到它不是超级用户,并且未禁用RLS。

As you can see it's not a superuser and it RLS isn't disabled on it.

我在做什么错了?

推荐答案

您忘记启用行表的安全级别。

You forgot to enable row level security for the table.

ALTER TABLE customer enable ROW LEVEL SECURITY;

force 仅确保应用了RLS

force only makes sure that RLS is applied if enabled, it does not enable RLS on the table.

在线示例:

这篇关于行级安全性不适用于表所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 19:15