Code

Opened 3 years ago

Closed 19 months 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 3 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 3 years ago.
Modify create_user and unit test.

Download all attachments as: .zip

Change History (12)

Changed 3 years ago by jorgeecardona

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 3 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 3 years ago by jorgeecardona

Modify create_user and unit test.

comment:2 Changed 3 years ago by ramiro

  • milestone set to 2.0
  • Needs documentation set
  • Triage Stage changed from Unreviewed to 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 Changed 3 years ago by NicoEchaniz

  • Cc NicoEchaniz added

comment:4 Changed 3 years ago by gabrielhurley

  • Component changed from Contrib apps to contrib.auth

comment:5 Changed 3 years ago by jaddison

  • Severity set to Normal
  • Type set to New feature

Somewhat related to #15089.

comment:6 Changed 3 years ago by jacob

Milestone 2.0 deleted

comment:3 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 19 months ago by aaugustin

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

comment:6 Changed 19 months ago by akaariai

  • Resolution set to fixed
  • Status changed from new to 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 Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.