Django 1.2 object level permissions - third party

2019-02-04 19:37发布

问题:

Since Django 1.2 final is almost out, I am curious if there are already projects that use the new object level permissions / row level permissions system. Django-authority, which is a possible solution for Django up to 1.1, has not been updated for a while, and does not (yet) use the new permissions system. It seems to me that Django-Authority is in a comatose state.

Does someone know about upcoming or maybe even finished solutions? I'd appreciate any good links to active projects with at least some downloadable content very much.

回答1:

I used https://github.com/lukaszb/django-guardian when it was still in version 0.2 on a project and it was rather complete and bug free.

Yes I did have to write my own 'check_permission' view decorator as at the time it didn't have it included yet - but at least from version 1.0 it is there.

The author was also very quick to respond to an issue I had migrating from 0.2 - overall I've been happy with it and hence made it part of my project skeleton template.



回答2:

Finally, I found really good stuff: Florian Apolloner wrote a howto on djangoadvent: http://djangoadvent.com/1.2/object-permissions/ Now that's what I'm gonna use :)

Something useful might be as well: http://github.com/washingtontimes/django-objectpermissions (link dead as of 2011-07-18)



回答3:

I have released a Django-app called django-rules which lets you manage per object permissions in a flexible, dynamic and scalable way. You might want to check it out.



回答4:

I tried using django-granular-permissions for a site a while ago, but was unable to get it to do what I needed (this may have been my own inability to understand what I needed to do rather than the app). Looking at the google code site's updates tab, it looks to not have had any work done on it since Summer/Autumn last year so it may be another dead duck.



回答5:

OSU Open Source Labs has an implementation of object level permissions here



回答6:

First of all, the main source of information is djangopackages.com's perms grid: "A grid of all packages implementing permissions for users and groups in your Django project". (Beware some packages are named very similarly, e.g. an 's' or a dash is the only difference)

Then, reviewing each package features (considering only the somewhat-actively maintained subset), these are the main candidates:

  • django-guardian: “implementation of per object permissions as authorization backend which is supported since Django 1.2.” pypi, repo, docs.

  • django-permissions: “Generic per-object permissions for Django”. “django-permissions provides per-object permissions for Django on roles”. pypi, original repo, most updated fork, docs.

  • django-authority: “provides generic per-object-permissions for Django's auth app.” “Django app for per-object-permissions that includes a bunch of helpers to create custom permission checks.” pypi, original repo, most updated fork, docs.

There are others that for one reason or the other did not make the cut:

  • django-object-permissions
  • django-rulez
  • django-permission

PS: This answer was written according to the current state of open source packages, more than 2 years after the question was asked. Although not too thorough, I hope this work will help those that are in the same situation I was.