Please (re)consider separate Nova policies #5134
-
I am aware that this issue has been brought up before (#131) but was then discussed in the context of multi-tenant applications. I'd like to propose another perspective as to why I believe it is worth considering defaulting to policy separation between the app and Nova: I appreciate that every project has different "expectations" of what an admin panel is supposed to do, but I'd argue that the following most commonly applies to user-facing Laravel projects:
For example, consider a medium-sized SaaS application:
When reading through Nova's documentation, the proposed solution is to utilize Nova's The problem with this approach is that it will quickly become very messy in the provided context. Essentially every single policy check throughout the application requires different logic for regular vs. Nova users. An alternative approach might be to leverage the A better workaround is probably to override policies in the But I'd argue Nova should separate these policies out of the box since this is the most sensible default for most applications (almost any SaaS app when the business scales beyond a certain size). It also doesn't downgrade the experience for projects who do have a lot of overlap in policy logic. After all, the Nova policy can simply extend the regular policy and only overwrite checks where necessary. Or alternatively, Nova may default to the regular policy if no Nova-specific policy exists for the given resource. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
@jerrebm, good points!
IMHO worth implementing. I am currently doing advanced acrobatics to separate Nova and non-Nova authorization logic :-/ |
Beta Was this translation helpful? Give feedback.
-
I also find myself spending less time writing an action than it takes to figure out the permissions around why I can't run the destructive action. I'd welcome simplification around these permissions. |
Beta Was this translation helpful? Give feedback.
-
We had the same problem here, and managed to separate it. We have the following structure:
We created a namespace for Nova Policies and extended the default policy so they only load inside nova. |
Beta Was this translation helpful? Give feedback.
-
Available in Laravel Nova 5: https://nova.laravel.com/docs/v5/resources/authorization#using-separate-policy-classes-for-nova-resources |
Beta Was this translation helpful? Give feedback.
Available in Laravel Nova 5: https://nova.laravel.com/docs/v5/resources/authorization#using-separate-policy-classes-for-nova-resources