AWS RDS Postgres/Iam Authentication/ and Row Level Security - All In One. Is this possible?

Viewed 438

I have an app that will have many users at various levels of privileges on what they can "See/Select".

The users form a hierarchy. Level1--> Level2--Level3 etc. Level1 users may have many level2 users, similarly Level2 users may have many level3 users . Each user can see anything that belongs to them or anyone directly below them. For example: A level 2 user can see all level 3 users information that rolls up to her but cannot see , any level 3 users that rolls up to other level 2 users.... You get the idea.

All userids are unique.

I am thinking of implementing Row Level Security with policies to restrict based on the userid. This is working at the database level by implementing Row level security and policies.

However, I would like to know how this can be achieved with IAM roles and IAM based authentication?

I read the documentation. It states, that while I can create a IAM roles and assign them privileges at the db level, and individual users can be assigned to these IAM roles to access the database using authtokens, it does not state how I can track each of the users at the database level to ensure that they can only see their data?

Any insights appreciated.

S

1 Answers

If you google "SaaS Multi-tenant Storage Isolation" You'll find a number of resources on this topic. The short answer is that you can achieve what you are trying to do (pool isolation enforced by IAM policies) with DynamoDB. But with RDS you have to rely on database users and PostgeSQL RLS features.

If you look at the IAM documentation for DyanmoDB and RDS condition keys, you'll see that with DynamoDB you can filter actions based on things like "dynamodb:LeadingKeys" or "dynamodb:Attributes". Where as RDS you do not have filters that get as granular as individual indicies or attributes.

Here's some addtional material on the topic worth looking at:

Related