postgresqlamazon-rdsmaskingdata-masking

Data masking using PostgreSQL at Amazon RDS, how to?


I was looking into this

https://postgres.ai/docs/database-lab/masking

and was searching how to mask (dynamically) my data using Amazon RDS PostgreSQL, but couldn't find any real solution.

Is there any one out there that solved that without recurring to server/backend masking?


Solution

  • If you want to retrieve readonly masked data I'd say to use views from the PostgreSQL. One way to achieve that would be:

    1. Create a new schema, for example: "masked"
    2. Create a new view inside the masked schema, with the same name as the table you want to mask your data dynamically. You'll set your masked rules on this said view.
    3. Create a new user role which will retrieve the masked data and change its search_path to look first for the masked schema SET search_path TO '$user', masked, public

    This way, if you make a query to select from the said table, it'll first look for the masked schema and if it has a view with the same name as the table you are doing your query, it'll retrieve the masked data from the rules applied to the view.