Django

Code

Ticket #9444 (closed: wontfix)

Opened 8 months ago

Last modified 4 months ago

[1.1 Pony] AnonymousUser that you can set specific permissions for

Reported by: Digitalxero Assigned to: nobody
Milestone: Component: Authentication
Version: 1.0 Keywords: Feature Request, Version 1.1
Cc: digitalxero@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The reason for this patch is because I do not like having to special case permissions for the AnonymousUser? for every model I wish to allow them access to.

I am working on an ACL that has no concept of User per say, it is using a generic relationship to maintain a list of subjects and objects that it controls, so subject and object can be any Model. In the ACL you will primarily use it for Users and Groups as subject and other models as objects, but you could potentially restrict one Models access to another (why I dont know but you can).

The fact that the AnonymousUser? has no model makes it impossible for me to add them as a subject to my ACL, or for any other permissions system to manage them other then special casing. Special casing is all well and good when you are not doing Row level permissions, as there are not going to be that many special cases, but once you start getting into row level permissions there could potentially be hundreds (or thousands) of cases when I would need to do special casing just for the AnonymousUser?, which is very un-DRY (IMHO)

This patch allows the creation of a user with the username BuiltinDjangoAnonymousUser?, and will return an instance of that User (if it exists) instead of the AnonymousUser? class. I added checking in the actual user model for this special user so that it will still return the proper values for is_authenticated, and is_anonymous, and so that noone could login as the special anonymous user. I also added a management command to create the new Anonymous User, and a signal listener to ask if you want to create one when you first install the Auth app.

Attachments

anonuser.models.patch (5.6 kB) - added by Digitalxero on 10/24/08 21:16:52.
django.contrib.auth.model Patch to include the new Special Anon user
anonuser.management.__init__.patch (1.5 kB) - added by Digitalxero on 10/24/08 21:17:39.
Add the Signal Listener to ask if they wish to create an Anon User
createanonuser.py (1.0 kB) - added by Digitalxero on 10/24/08 21:18:12.
The actual createanonuser Management command

Change History

10/24/08 21:16:52 changed by Digitalxero

  • attachment anonuser.models.patch added.

django.contrib.auth.model Patch to include the new Special Anon user

10/24/08 21:17:39 changed by Digitalxero

  • attachment anonuser.management.__init__.patch added.

Add the Signal Listener to ask if they wish to create an Anon User

10/24/08 21:18:12 changed by Digitalxero

  • attachment createanonuser.py added.

The actual createanonuser Management command

12/12/08 23:48:32 changed by mtredinnick

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to wontfix.
  • needs_tests changed.
  • needs_docs changed.

None of the core maintainers were in favour of this feature when we discussed 1.1 features (it ended up with eight -1 votes and one -0 out of nine voters).

02/25/09 13:51:44 changed by

  • milestone deleted.

Milestone post-1.0 deleted


Add/Change #9444 ([1.1 Pony] AnonymousUser that you can set specific permissions for)




Change Properties
Action