I have made a permission_required
decorator
#776
baseplate-admin
started this conversation in
Show and tell
Replies: 1 comment 6 replies
-
I've implemented something similar here: https://github.com/OtherBarry/django-ninja-decorators/blob/master/ninja_decorators/permissions.py This uses string based permissions rather than permission classses, because my use case was for granular permissions. It wouldn't be too difficult to combine the two methods though. A third party package would be great! |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I needed a reusuable way to check for user permissions.
Couple of facts :
auth
is passed inside router. Eg : This will work@router.post("", response=SomeSchema, auth=AuthBearer()) # Note the auth here ?
@router.post("", response=SomeSchema, login=AuthBearer())# Note that theres no auth here. So we can't do `request.auth`
If there's enough interest. I can make it a 3rd party package that will help other developers on their journey
This decorator was mostly inspired from #580 (comment)
Beta Was this translation helpful? Give feedback.
All reactions