0

We need to implement row-level security policy for a PostgreSQL View. Is there any option to do this?

Thank You

tanius
  • 14,003
  • 3
  • 51
  • 63
  • Does this answer your question? [Why isn't row level security enabled for Postgres views?](https://stackoverflow.com/questions/33858030/why-isnt-row-level-security-enabled-for-postgres-views) – tanius Feb 02 '23 at 01:27

1 Answers1

1
CREATE VIEW
  view_own_log
AS SELECT
  these,
  fields,
  only
FROM
  restricted_log_table
WHERE
  username=user;

user is the logged on user.

You can create more sophisticated WHERE clauses if needed. Have the table access limited to minimum and use GRANT to give access to the view.

Vesa Karjalainen
  • 1,087
  • 8
  • 15