This project has moved and is read-only. For the latest updates, please go here.

Multi-tenancy

Oct 8, 2013 at 2:25 AM
Is there any way to support multi tenancy in MongoDb using MongoRepository? I want to override the queries at a low level to ensure that the tenantId column is queried on to ensure the security of mingled data.

Any idea how I could do this? Considering I am using the Mongo C# driver and MongoRepository.

Thanks in advance,
Tyson
Oct 8, 2013 at 3:49 PM
Edited Oct 8, 2013 at 3:50 PM
This is, unless I misunderstand you, not the responsibility of a (generic) Repository like MongoRepository is. You can derive your own repository class and implement the required things to make it "multitenant".

But I might be misunderstanding you so you could try to elaborate if you don't agree with my opinion.
Oct 9, 2013 at 4:58 AM
You're right Rob,

I was mostly reaching out to see if you had ideas on the subject, as you have the skill to implement this excellent project. I believe I could not rely on a derived repository to implement the multi-tenancy data security. As i am using the C# driver and calling the aggregation command (and others), which goes directly to the repository's collection.

Kind regards,
Tyson
Oct 9, 2013 at 9:28 AM
I don't know about your exact setup, but I think I would define an IMultiTenantObject interface and give it some "tenant ID" property and have entities implement this interface and have the repositorie(s) restricted to IMultiTenantObjects.