Policy references
As shown in the diagram, I'm in a scenario where a container resource has a policy that permits access by either being the creator or a collaborator.
Is there a way to not have to repeat this logic in all the child resources, such that I could be properly authorized on
Item
's read action?
I think it's possible to use accessing_from
to allow reads of items when loading through containers, but that doesn't solve for direct access.
I guess this isn't the worst solution in the world…
But I'd much rather have something like
So a change to the container rules wouldn't require a policy change in all child resources of the container.
7 Replies
this shouldn't be hard to implement, you can just create a simple check and use Ash.can? to see if the current actor can read the other resource
That makes sense. I'll probably end up using the relate via to get filtering though, since that simple check wouldn't interact with the DB—right?
Solution
My suggestion is to use calculations for this.
Then in the child resource
🤯 that makes a lot of sense
I'd like to implement a
can_read
pattern, its just a bit complex and requires "analysis" of the policies to determine if it can be done as a filter or requires running queries etc.I had a feeling this was more tricky because policies are so flexible that being able to read isn't universal
Thanks both of you!