model_permissions.backends

class model_permissions.backends.BaseObjectBackendMixin[source]

Bases: object

Base class for object permission backends.

get_permission_function(obj)[source]

Get the function to list the given objects permissions.

This checks the given object for a get_permissions method and, if it doesn’t exist, the MODEL_PERMISSIONS setting to find the objects Permission Function.

Parameters:obj (django.db.models.Model) – The model instance to get the function for.
Returns:The function to list the objects permissions.
Return type:callable
model_permission_wrapper(user_obj, obj)[source]

Object permission wrapper for the get_permissions model method.

get_object_permissions(user_obj, obj=None)[source]

Get object permissions for the given user and object.

Exit early and return an empty set if:

  • no object is given

  • the user is

    • inactive
    • anonymous
    • a superuser
  • no permission function can be found

Parameters:
Returns:

Set of permissions.

Return type:

set

class model_permissions.backends.ObjectModelBackendMixin[source]

Bases: model_permissions.backends.BaseObjectBackendMixin

Mixin for dual permission authentication backends.

get_all_permissions(user_obj, obj=None)[source]

Get all permissions for the given user and object.

class model_permissions.backends.ObjectBackendMixin[source]

Bases: model_permissions.backends.BaseObjectBackendMixin

Mixin for object-only permission authentication backends.

get_all_permissions(user_obj, obj=None)[source]

Get all permissions for the given user and object.

class model_permissions.backends.ObjectBackend[source]

Bases: model_permissions.backends.ObjectBackendMixin, django.contrib.auth.backends.ModelBackend

An authentication backend with object permissions only.

class model_permissions.backends.ObjectModelBackend[source]

Bases: model_permissions.backends.ObjectModelBackendMixin, django.contrib.auth.backends.ModelBackend

An authentication backend with default and object permissions.

class model_permissions.backends.AllowAllUsersObjectBackend[source]

Bases: model_permissions.backends.ObjectBackendMixin, django.contrib.auth.backends.AllowAllUsersModelBackend

Django’s AllowAllUsersModelBackend with object permissions only.

class model_permissions.backends.AllowAllUsersObjectModelBackend[source]

Bases: model_permissions.backends.ObjectModelBackendMixin, django.contrib.auth.backends.AllowAllUsersModelBackend

Django’s AllowAllUsersModelBackend with dual permissions.

class model_permissions.backends.RemoteUserObjectBackend[source]

Bases: model_permissions.backends.ObjectBackendMixin, django.contrib.auth.backends.RemoteUserBackend

Django’s RemoteUserBackend with object permissions only.

class model_permissions.backends.RemoteUserBackend[source]

Bases: model_permissions.backends.ObjectModelBackendMixin, django.contrib.auth.backends.RemoteUserBackend

Django’s RemoteUserBackend with dual permissions.

class model_permissions.backends.AllowAllUsersRemoteUserObjectBackend[source]

Bases: model_permissions.backends.ObjectBackendMixin, django.contrib.auth.backends.AllowAllUsersRemoteUserBackend

Django’s AllowAllUsersRemoteUserBackend with object permissions only.

class model_permissions.backends.AllowAllUsersRemoteUserBackend[source]

Bases: model_permissions.backends.ObjectModelBackendMixin, django.contrib.auth.backends.AllowAllUsersRemoteUserBackend

Django’s AllowAllUsersRemoteUserBackend with dual permissions.