I’m aware of the various multi-tenant approaches with Cognito and I’ve mentally committed to the “one user pool per tenant” method. So, for example, our AWS account would have tenant_a_user_pool for tenant A and tenant_b_user_pool for tenant B, etc. BUT, now that I’m ready to implement this approach, I’m starting to have second thoughts and I’m wondering if I could do something more simple with one user pool while still achieving my goals, which are: security and flexibility
Regarding security, I’ve made the assumption that having users separated by user pool is inherently more secure just by the sheer nature of having users separated. So, my first questions are:
- Are separate user pools more secure?
- Or, can it be equally secure using one user pool with tenant/user relationship info stored in a database?
As for flexibility, having “one user pool per tenant” will allow for configuring SAML authentication for tenant A while tenant B might choose another authentication method, say authenticating with un/pw against their user pool. Or, tenant C can turn on MFA and tenant D might leave it off. While I don’t doubt that this approach can be flexible, I am starting to wonder if it is too complex and if I can achieve the same using one user pool?
If I go with one user pool for all users, I was thinking of an approach such as this:
In the model above, I’ve added an association table, tenant_users, as there might be a requirement to have users be part of multiple tenants while using one set of login credentials (similar to Slack, I’d say). But, if I go this approach, I start to wonder about flexibility. For example, can I still have tenant A use SAML and tenant B use some other authentication method? If you notice in the tenants table, I’ve added an auth_methods column which would store the tenants preferred authentication method. I’m hoping I can add the authentication logic for the various authentication methods in a lambda invoked by a Cognito trigger. But, I’m heading into unfamiliar territory so I don’t know what’s possible or not.
To recap, my questions are…
- Is one user pool for all tenants just as secure as one user pool per tenant?
- Can I maintain flexibility (e.g. allow tenants to choose different authentication methods) with one user pool if I add an auth_methods column to the tenants table that specifies each tenant's authentication preferences?
Any other comments on this overall approach would be greatly appreciated.