Authorization Policies #45
lonnieezell
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
I think it sounds very good. We will just need easy access to the policy instance in the view. |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Just a heads up: I'm implementing a Policies feature for authorization. I think this will help us handle the general errors and authorization checking within our controllers. Here's a basic run-down of what I'm working on:
threads.create$user->can('threads.create'). If it fails, it will return redirect through HTMX to display a pre-defined error page that the status and error message is passed along to. I think that's the simplest way to get the errors working both within and outside of an HTMX call.This also allows defining new classes to handle additional logic for the permissions check. Assuming we have a permissions
threads.edityou could check the policy similar to above, but passing the thread instance along with it.Then in the policy class, which is based on the permission name for class name/method:
You can also do more broad-based checks with a
beforemethod in the policy, like granting superadmins and admins permission to all the things:Any concerns with this?
Beta Was this translation helpful? Give feedback.
All reactions