Skip to main content

row_security

Function row_security 

Source
pub async fn row_security<S: AsRef<str>>(
    pool: &PgPool,
    tables: &[S],
) -> Result<RowSecurity, Error>
Expand description

Ask Postgres whether row-level security can apply to pool’s role, and whether each of tables, such as todos or app.todos, has it enabled and forced.

A policy does nothing for a superuser or a role with BYPASSRLS, and nothing for a table’s owner unless the table has FORCE ROW LEVEL SECURITY. Each failure is silent: every query still answers, with every tenant’s rows. Call this at boot, after migrating, and refuse to serve when it does not hold.

§Errors

Any error from the queries.