I try to create an Django app which will work for multiple domains with single app instance.
For example:
- there are three domains: group1.com, group2.com, group3.com
- each domain has restricted content available after login
- user1 is associated with group1.com and group2.com
- when user1 log in to group1.com and try to enter group2.com, he will be automatically log in into the group2.com
- there is URL, e.g. DOMAIN_NAME/posts/ which will show all content for user which is logged in from all domains which are associated with this user (in this case, for user1 there should be all "posts" from group1.com and group2.com)
- when user1 enter group3.com, he's not logged in
I used Django Site framework to associate user with domains - content restriction for user in specific domains works fine.
Additionally, I used SESSION_COOKIE_DOMAIN parameter in settings.py for "share" cookie between domains and, unfortunately, it only works for subdomains. For example, after set:
SESSION_COOKIE_DOMAIN = '.group.com'
and after I wrote simple middleware, I'm able to meet the requirements that I wrote above but only for subdomains, like 'one.group.com', 'two.group.com', 'three.group.com'.
I was looking for solution for handle that, but I haven't found an answer for newest Django 3.x framework.
Is there any way to handle that like I explained?