Replies: 1 comment 1 reply
-
|
The decorators read the values from the logged-in For roles, use the plural decorator For permissions, Example: from bustapi.auth import BaseUser, roles_required, permission_required
class User(BaseUser):
def __init__(self, id):
self.id = id
self.role = "admin"
self.permissions = ["posts:delete", "users:read"]
@app.get("/admin")
@roles_required("admin")
def admin():
return {"ok": True}
@app.post("/posts/delete")
@permission_required("posts:delete")
def delete_post():
return {"deleted": True}The important part is that your |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
how to set permissions or roles to active @permission_required or @role_required?
Beta Was this translation helpful? Give feedback.
All reactions