django-view-permissions 0.0.2

Creator: danarutscher

Last updated:

Add to Cart

Description:

djangoviewpermissions 0.0.2

django-view-permissions provides ways to control access for Django app views

Overview
Checks the incoming requests, to grant or deny access for views accoding to
the permissions defined in the views. If permissions attribute is not defined
in the view, normal django flow is followed. If permissions attribute is
defined in view it checks and grants or denys access of the view.


Installation
Install the latest release using pypi:
pip3 install django-view-permissions
Add the application to the INSTALLED_APPS:
INSTALLED_APPS = (
...
# DjangoViewPermissions
'django_view_permissions',
)
Add the middleware to the configuration:
MIDDLEWARE_CLASSES = (
...
'django_view_permissions.middleware.DjangoViewPermissionsMiddleware',
)


Usage
Currently, 3 ways to define permissions are supported.


Attribute based permissions
Method based permissions
Class based permissions


Below is a Attribute based permission example. Where view will be only accessable
to users whose attribute ‘is_staff’ is ‘True’.
class DummyView(View):
permissions = [
('attr', 'is_staff', True),
]
In Method based permissions, you will need to defind the method with a ‘request=None’
argument and a boolean return statement. All the requests for which method returns
‘True’ will be able to access the view.
class DummyView(View):
permissions = [
('method', permission_method),
]
In Class based permissions, you will need to defind a class with a ‘request=None’
argument in __init__ method. All the requests for which __call__ method returns
‘True’ will be able to access the view.
class DummyView(View):
permissions = [
('class', PermissionClass),
]
Note: It is recommended to define the permission methods or classes in a separate file.
Please check permissions.py for examples.


License
The code in this repository is licensed under the Apache Software License 2.0 unless
otherwise noted.
Please see LICENSE for details.


How To Contribute
Contributions are very welcome.
Please read How To Contribute for details.


Reporting Security Issues
Please do not report security issues in public. Please email muhammadayubkhan6@gmail.com.


Getting Help
Feel free to create git issues in case of queries/issues/enhancements.


Change Log

Unreleased
Added

_



[0.0.2] - 19-03-2020
Added

Fix some documention and release issues.



[0.0.1] - 19-03-2020
Added

Automatic upload to PyPI on tags.
Documentation



[0.0.dev0] - 17-03-2020
Added

Attr based permissions
Method based permissions
Class based permissions
First release on PyPI.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.