Comments (2)
I have not yet had to make that distinction, but I see your point. I think this could be accomplished with DRF's custom exception handling and a custom exception class:
https://www.django-rest-framework.org/api-guide/exceptions/#custom-exception-handling
In the condition check that fails in the access policy, the custom exception could be raised and the custom exception handler could examine the type of exception raised and alter the response accordingly. DRF permissions are intended to return booleans, not raise exceptions, so maybe this isn't ideal.
from drf-access-policy.
@lorinkoz #45 is similar. I added some notes about an approach I am experimenting with that could possible be useful: #45 (comment)
from drf-access-policy.
Related Issues (20)
- Can I write all policies in one json file? HOT 1
- Inconsistent expression parsing
- How to apply access policies to class based views
- Version 0.8.5 breaks conditions with `*` as params HOT 1
- Default value "effect": "allow"
- Introduction of support for condition expressions is a breaking change on existing condition strings HOT 2
- [BUG] bool type error HOT 6
- `view.get_object()` raises AssertionError inside condition method HOT 1
- Reusable conditions not working
- Why "principal: authenticated" is "not anonymous" instead of "is authenticated"? HOT 1
- [Question] Dealing with unnecessary repetition of DB hits... HOT 1
- [BUG] <lambda>() missing 1 required positional argument: 'token' HOT 3
- Support db statements
- How to implement field based access as mentioned in the docs? HOT 1
- Include additional information in permission denied response HOT 1
- Order of inheritance of AccessViewSetMixin in Viewset matters? HOT 1
- Enforce access policy through PrimaryKeyRelatedField HOT 3
- FieldAccessMixin with read_only=True serializer requires request attribute HOT 2
- Documentation webpage doesn't work HOT 1
- Documentation bug: reusable conditions method should not use "self". HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drf-access-policy.