[FEATURE]: Custom Policy Check - HasPermission #343
Labels
No labels
bug
duplicate
enhancement
help wanted
high priority
invalid
L
low priority
M
medium priority
needs refinement
optional
question
S
UX research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#343
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description:
Create the core custom Ash Policy Check that reads permissions from the
PermissionSetsmodule and applies them to Ash queries. This is the bridge between hardcoded permissions and Ash's authorization system.Tasks:
lib/mv/authorization/checks/has_permission.exuse Ash.Policy.Checkdescribe/1- returns human-readable descriptionmatch?/3- the core authorization logic:actor.role.permission_set_namePermissionSets.permission_set_name_to_atom/1PermissionSets.get_permissions/1apply_scope/3helper::all→:authorized(no filter):own→{:filter, expr(id == ^actor.id)}:linked→ resource-specific logic:{:filter, expr(user_id == ^actor.id)}{:filter, expr(member.user_id == ^actor.id)}(traverse relationship!){:error, :no_actor}{:error, :no_role}{:error, :invalid_permission_set}{:error, :no_permission}@docwith examplesAcceptance Criteria:
Ash.Policy.Checkbehaviormatch?/3correctly evaluates permissions from PermissionSets:linkedscope handles Member and CustomFieldValue differentlyTest Strategy (TDD):
Permission Lookup Tests:
Scope Application Tests - :all:
Scope Application Tests - :own:
Scope Application Tests - :linked:
Error Handling Tests:
match?with nil actor returns{:error, :no_actor}match?with actor missing role returns{:error, :no_role}match?with invalid permission_set_name returns{:error, :invalid_permission_set}match?with no matching permission returns{:error, :no_permission}Logging Tests:
Test Files:
test/mv/authorization/checks/has_permission_test.exs