I want to expose a user/accounts table via an API and secure it on the PostgreSQL level.
Using row-level security has worked great for my other tables, but on the accounts table I have some data that I don't want the user to be able to view or edit even on his own row (such as the locked state, number of failed logins and some internal fields).
My first thought was to hide the actual table away in a different scheme and define a view with only the fields I want accessible. But row-level security doesn't accept that. According to this site here: https://www.benburwell.com/posts/row-level-security-postgresql-views/ - that's a problem of views and ownership. But that was 2020. Maybe something changed? His solution wouldn't work for me because I also want to write into the table.
Is there a solution to implement row-level security in 2022 with current PostgreSQL version? Or is there a better workaround that allows writing?
related info:
- (this related question is also 3 years old, and might not be true for current versions)
- (the official docs are silent on RLS and views)