1

I found this post (Multi-tenanted DB. Strategy for Document ID and authorization) and I'm trying to modify my base repository similar to the first answer or the second answer. I understand both answers are good for RavenDB, however, my backend database is MongoDB and I was wondering if I can implement similar approach for my MongoDB base repository.

Thanks,

Edit1: to be more specific this is the problem I'm trying to solve: currently for authorization we add the TenantID to every query we run against our database/collections. And sometimes developer forget to add the TenantID (so potentially an attacker can have access to other tenant's data). What I want to do is to force add the TenantID to be always as part of queries we run against the DB. similar to what people suggested in the fist and the second answers above.

Update: I found a way, I used Builders < T > to pass what I need to base functions in my BaseRepository and then I add the TenantID to query there. This solved my problem.

Sohail
  • 11
  • 4
  • Welcome to Stack Overflow. Please review [ask]. This site is focused more on Q&A around specific coding problems and works best when you share the code that you have written and include a specific problem. – Jason Armstrong Dec 12 '18 at 15:45
  • @JasonArmstrong, thank you, currently for authorization we add the TenantID to every query we run against our database/collections. And sometimes developer forget to add the TenantID (so potentially an attacker can have access to other tenant's data). What I want to do is to force add the TenantID always as part of queries we run against the DB. similar to what people suggested in the fist and the second answers under the post I shared. – Sohail Dec 12 '18 at 16:21
  • @Sohail can you breifly explain on the above mentioned solution? what exactly is Builders < T >? I am using mongodb package and want to impose a created_by field in documents. – ns15 May 30 '19 at 11:33
  • Can you share how did you accomplished that ? – Herbert Pimentel Feb 25 '20 at 23:11

0 Answers0