Add db_post_request Hook for Dynamic Data Masking in PostgREST - Complex authorization methods implementation #3832
-
ProblemCurrently, there is no way in PostgREST to dynamically mask or manipulate output data before it is sent to the client. While Row-Level Security (RLS) and Column-Level Security (CLS) provide robust mechanisms for access control, there are scenarios where these mechanisms are insufficient to handle complex authz rules. For example:
This is difficult to achieve securely without duplication or using external middleware:
A feature to mask or manipulate output dynamically at the SQL level—just before returning the response—would enable more powerful authorization models like Attribute-Based Access Control (ABAC) without relying on external systems. SolutionIntroduce a
Benefits:
Do you have another solution without using a custom backend between client and PostREST? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
A couple of thoughts:
All of that being said, PostgREST does have a way to influence the output, too: You could implement a custom aggregate to override the built-in media type handler for json: https://docs.postgrest.org/en/v12/references/api/media_type_handlers.html#overriding-a-builtin-handler. This would allow you to do anything you want to the update. However, I strongly advise against this. Look into the various anonymization extensions, which are much better for security. |
Beta Was this translation helpful? Give feedback.
A couple of thoughts:
SECURITY LABEL
s.All of that being said, PostgREST does have a way to influence the output, too: You could implement a custom aggregate to override the built-in media type handler for json: https://docs.po…