Skip to content

File upload authorization shouldn't apply to actions #4128

@aburgel

Description

@aburgel

Describe the bug

We ran into an issue where we lost permissions to upload files on an action because of a change in one of our policies. It was surprising that the upload_{field}? permission applies to actions. The documentation doesn't mention this. Actions aren't necessarily 1 to 1 with a resource, they seem purposefully design to work with multiple kinds of resources. Plus none of the other permissions apply to the action itself. (Yes, act_on? determines whether you can use the action, but that controls behavior on the resource itself, not within the action.)

Steps to reproduce

  1. Create a resource with an authorization policy that doesn't allow upload_file?
  2. Create an action with a file upload field named file
  3. Open the action and observe that you cannot upload a file

Expected behavior & Actual behavior

Expected behavior is that authorization policies don't apply within an action (just to the resource that invokes the action).

Actual behavior is to hide the upload field if the outer resource authorization policy doesn't allow upload_{field}?

System configuration

Avo version: 3.26.1

Rails version: 8.0.1

Ruby version: 3.4.7

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Additional context

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions