Replies: 1 comment 5 replies
-
|
You're linking to Laravel Nova 1 documentation. However, |
Beta Was this translation helpful? Give feedback.
5 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.
-
A resource's
indexQuerycurrently ignores any policy view constraints, as documented here. This leads to significant code duplication for more security-conscious applications, as they have to implement a policyviewfunction for each resource to restrict access and then implement the same logic again in the resource'sindexQuery(as any logged in user can issue an http://.../nova-api/some-resource query to get the resource index). The access code cannot be shared, as the policy applies the logic to objects, while the indexQuery applies it to an Eloquent query. This means significant logic duplication, and the potential for inconsistencies and errors.I would personally prefer the
indexQueryto apply the view policy and only return permitted results. However there may be good reasons why it doesn't, and it would be a breaking change to existing code. So I suggest that there be a boolean variable in the Resource class which determines whether theindexQueryrespects the view policy or not, and that the variable defaults tofalse. This would allow existing code to continue working while giving the opportunity for developers to centralise access controls if they want to.Beta Was this translation helpful? Give feedback.
All reactions