Can I use row-level-security for application users?

For my webservice I use a PostgreSQL database which supports row-level-security to prevent users accessing rows of a table they are not supposed to read/access. I would like to use this functionality to prevent a user accessing data from another user (either due to a bug, altered webservice request, SQL injection, etc).

I understand the purpose is actually meant for a database user, but I am wondering if it is wise or common to create a shadow-user in the database for every “application” user as well. (the database is of course not directly accessed and rather through a WSGI, therefore the shadow user)

FYI: This is techically a XY-problem. Means, my actual intention is to prevent that a user requested e.g. his profile and due to an accident or corner case accidentally data from another profile gets send back. Row-Level access looked promising

Go to Source
Author: Daniel Stephens