Opened 6 years ago

Closed 4 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:

http://code.djangoproject.com/ticket/15089

Attachments (2)

add_site_field.patch (1.8 KB) - added by jorgeecardona 6 years ago.
Add a site field in user with null=True and default=None, and a new constraint for uniquness between username and site.
modify_create_user_and_tests.patch (3.9 KB) - added by jorgeecardona 6 years ago.
Modify create_user and unit test.

Download all attachments as: .zip

Change History (12)

Changed 6 years ago by jorgeecardona

Attachment: add_site_field.patch added

Add a site field in user with null=True and default=None, and a new constraint for uniquness between username and site.

comment:1 Changed 6 years ago by jorgeecardona

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

I changed the create_user method in UserManager in order to receive a site object, and also made some testes for integrity error.

Changed 6 years ago by jorgeecardona

Modify create_user and unit test.

comment:2 Changed 6 years ago by Ramiro Morales

milestone: 2.0
Needs documentation: set
Triage Stage: UnreviewedSomeday/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 Changed 6 years ago by NicoEchaniz

Cc: NicoEchaniz added

comment:4 Changed 6 years ago by Gabriel Hurley

Component: Contrib appscontrib.auth

comment:5 Changed 5 years ago by James Addison

Severity: Normal
Type: New feature

Somewhat related to #15089.

comment:6 Changed 5 years ago by Jacob

Milestone 2.0 deleted

comment:3 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:5 Changed 4 years ago by Aymeric Augustin

Isn't this problem essentially solved by the custom user models introduced in Django 1.5?

comment:6 Changed 4 years ago by Anssi Kääriäinen

Resolution: fixed
Status: newclosed

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).

Note: See TracTickets for help on using tickets.
Back to Top