honor ash policies for authorizating belongs_to relation#11
honor ash policies for authorizating belongs_to relation#11bars0udin wants to merge 4 commits intoenoonan:mainfrom
Conversation
|
Thanks so much! This looks really great. I've been aware of this problem, and it's one of the reasons the README still warns people to only use AshBackpex for internal admin tooling in trusted environments. I've been sick for a couple weeks and I'm on a heavy dose of antibiotics at the moment. But I'll be sure to review / merge / tag / release this ASAP when I'm back to my normal self. ~E |
|
Sorry to hear you're not feeling well, hope you feel better soon! |
|
Hello - I'm going to have to take a close look at this. CI tests are failing and it looks like it breaks the field type derivation code. |
|
The failure is basically that the test for BelongsTo now needs to match the |
Out of the box, ash policy is not honored when loading a relating resource. This is an initial attempt to address this. I would like to also update the demo to demonstrate what this update will address.
Add Ash Authorization Support to BelongsTo Fields
Problem
BelongsTo dropdowns showed ALL related records, ignoring Ash authorization policies.
This caused information disclosure - users could see records they shouldn't access.
Solution
Created custom
AshBackpex.Fields.BelongsTothat:Ash.read(actor: actor)to respect policiesChanges
lib/ash_backpex/fields/belongs_to.ex- Ash-aware BelongsTo fieldlib/ash_backpex/live_resource/transformers/generate_backpex.ex:178- Use new fieldlib/ash_backpex/live_resource/dsl.ex:135-147- Updated docsImpact
Dropdowns now automatically respect Ash policies without additional configuration.
Demo Update Example
File: demo/lib/demo/accounts/resources/workspace.ex
Demo Scenario: