Opened 14 years ago
Closed 12 years ago
#15110 closed New feature (fixed)
User Isolation between sites.
Reported by: | jorgeecardona | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.2 |
Severity: | Normal | Keywords: | multitenancy |
Cc: | NicoEchaniz | Triage Stage: | Someday/Maybe |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I want to add a feature in which the users can be isolated between sites, in order to improve multitenancy in django.
I added to auth.User a site field as ForeignKey with null=True and default=None, and in Meta a unique_together=('name', 'site'). The actual tests run without problem with that.
I will add more tests soon.
Ref:
Attachments (2)
Change History (12)
by , 14 years ago
Attachment: | add_site_field.patch added |
---|
comment:1 by , 14 years ago
I changed the create_user method in UserManager in order to receive a site object, and also made some testes for integrity error.
by , 14 years ago
Attachment: | modify_create_user_and_tests.patch added |
---|
Modify create_user and unit test.
comment:2 by , 14 years ago
milestone: | → 2.0 |
---|---|
Needs documentation: | set |
Triage Stage: | Unreviewed → Someday/Maybe |
The problem with a change like this (similarly to other proposals made before to change the schema of often used contrib.*
apps models) is that it will mean everybody will need to manually modifiy the structure of the DB table(s) associated with the modified model(s).
Moving to the 2.0 milestone, when it hopefully will be worth considering all these backward incompatible changes.
comment:3 by , 14 years ago
Cc: | added |
---|
comment:4 by , 14 years ago
Component: | Contrib apps → contrib.auth |
---|
comment:5 by , 12 years ago
Isn't this problem essentially solved by the custom user models introduced in Django 1.5?
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
For the usermodel.site field: yes.
I don't think we want to drag this ticket into solving all possible problems when having multiple users with same username, but different site. If there are places which makes this usecase extra complicated lets consider fixing those in separate tickets.
So, closing this as fixed (by custom user models).
Add a site field in user with null=True and default=None, and a new constraint for uniquness between username and site.