django-authority | Django | Authorization library
kandi X-RAY | django-authority Summary
kandi X-RAY | django-authority Summary
A Django app that provides generic per-object-permissions for Django's auth app and helpers to create custom permission checks.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns a list of objects to edit
- Return whether the group has permissions for the given group
- Check if user has given permission
- Return whether the user has the given permission
- Add a permission request
- Shortcut for 403 Forbidden response
- Return the URL for the given object
- Get next URL
- Return the link to the delete permission request
- Get permissions for an object
- Get permission requests
- Returns the user s permissions cache
- Return the permission cache
- Check if the given token has a permission
- Return a list of choices for the given model
- Renders the link to delete foreign permissions
- Return the permission cache for the user
- Render a permission request
- Resolve the variables
- Get permission request
- Validates the group
- Render a form field
- Render permission form
- Validates that the user has the given permissions
- Register a model or iterable
- Get permissions for object
django-authority Key Features
django-authority Examples and Code Snippets
Community Discussions
Trending Discussions on django-authority
QUESTION
I am building a quite complex Django
application to be used on top of and email scanning service. The Django
application is written using Python 3.5+
This application primarily uses Django Rest Framework
to handle communication with the frontend in the browser.
The issue that I am currently having is that I try to implement the concept of a System Administrator
, Domain Administrator
and Application User
The System Administrator
is basically the "normal" django superuser
and is therefore capable of doing everything and see every record in the system.
The Domain Administrator
is user who manages one or more email domains
. I keep track of this using a Many2Many
relationship between the users
and the domains
. The idea would then be to predefine a filter, so that the log of messages processed, will be automatically filtered to show only messages where the sender domain
or the recipient domain
equal a domain
in the list of domains
that the given user
is assigned to.
The same would be true for blacklisting
/whitelisting
policies.
If the Domain Administrator
is not assigned to any domains
, then no data is shown.
The Application User
is basically any authenticated user with one or more domains
assigned to them, using the same Many2Many
relationship as the Domain Administrator
. If no domains are assigned, then no data is shown.
I have found some other solution here on Stackoverflow on making the request.user
available to the QuerySet
in the ModelManager
, but that does not seem like the correct way to handle it.
I have looked at django-guardian
, django-authority
and django-permissions
, but none of them seem to be affecting the QuerySet
or the resulting list of objects.
Does anyone have a suggestion for Django package/addon that can be used to handle this or maybe an idea for how this could be handled?
...ANSWER
Answered 2018-May-18 at 18:02DRF's GenericAPIView
has a get_queryset
method that you can override to perform custom filtering:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-authority
You can use django-authority like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page