Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for scoping checks #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,26 @@ operation is allowed.
In these arguments `request` is current request, `object` is the object we are
trying to add, change or delete. And `values` is a dict of the values we are
trying to save. In case of `delete` this is always empty.


### Check permissions & scoping for requests
Based on whether the created endpoint accepts a `GET`, `PUT`, `POST`, ... a set of scopes is defined that need to be checked.

The following scopes are checked automatically when calling the following methods

Get scoping:
- view.get_queryset()

Change scoping:
- view.store(obj, fields, request)

## @no_scoping_required()
In some cases you might not need the automated scoping. An example might be when your endpoint does not make any
changes to the data-model but simply triggers an event or if you have already implemented custom scoping. In that
case there is the option of adding `@no_scoping_required()` before the endpoint, which will ignore the scoping checks for the endpoint.

```python
@detail_route('download', methods=['POST'])
@no_scoping_required()
def download(self, request, pk):
```
Loading