You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a custom controller and delegating permissions on another resource, the resource is treated as a parent and defaulting the action to :show instead of the controller's action.
If run authorization against the :show action is actually intended, at least a section in the documentation should be present to warn people that setting the resource on the load_and_authorize_resource helper without setting the parent_action: option and in controller named differently that the resource will cause authorization always check to the :show action which is pretty permissive in general.
I agree completely with the point, but I disagree with the fix. I believe the load_and_authorize_resource :book should recognise that :book is actually not a parent.
I agree completely with the point, but I disagree with the fix. I believe the load_and_authorize_resource :book should recognise that :book is actually not a parent.
Ok, let me close the PR with this comment, I'll come back later to have a better fix for this.
Steps to reproduce
When creating a custom controller and delegating permissions on another resource, the resource is treated as a parent and defaulting the action to
:show
instead of the controller's action.A non admin user can perform the
:update
action when it shouldn't.Expected behavior
It should delegate the permissions on the resource set in the helper.
Actual behavior
It applies the
:show
action permission because is hard coded unless you set theparent_action:
optionSystem configuration
Rails version: 5.2.2
Ruby version: 2.7.0
CanCanCan version: 3.3.0
The text was updated successfully, but these errors were encountered: