[FEATURE]: PermissionSets Elixir Module (Hardcoded Permissions) #323
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#323
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
PermissionSetsmodule that defines all four permission sets with their resource and page permissions. This is the heart of the MVP's authorization logic.Tasks:
lib/mv/authorization/permission_sets.ex@moduledocexplaining the 4 permission setsget_permissions/1for each of the 4 permission setsall_permission_sets/0returning[:own_data, :read_only, :normal_user, :admin]valid_permission_set?/1checking if name is in the listpermission_set_name_to_atom/1with error handling@docexamples for each functionPermission Set Details:
1. own_data (Mitglied):
["/", "/profile", "/members/:id"]2. read_only (Vorstand, Buchhaltung):
["/", "/members", "/members/:id", "/properties"]3. normal_user (Kassenwart):
["/", "/members", "/members/new", "/members/:id", "/members/:id/edit", "/properties", "/properties/new", "/properties/:id/edit"]4. admin:
["*"](wildcard = all pages)Acceptance Criteria:
get_permissions/1returns correct structure for each setvalid_permission_set?/1works for atoms and stringspermission_set_name_to_atom/1handles errors gracefully@docand@specTest Strategy (TDD):
Structure Tests:
get_permissions(:own_data)returns map with:resourcesand:pageskeys:resource,:action,:scope,:grantedPermission Content Tests:
:own_dataallows User read/update with scope :own:own_dataallows Member/Property read/update with scope :linked:read_onlyallows Member/Property read with scope :all:read_onlydoes NOT allow Member/Property create/update/destroy:normal_userallows Member/Property full CRUD with scope :all:adminallows everything with scope :all:adminhas wildcard page permission "*"Validation Tests:
valid_permission_set?("own_data")returns truevalid_permission_set?(:admin)returns truevalid_permission_set?("invalid")returns falsepermission_set_name_to_atom("own_data")returns{:ok, :own_data}permission_set_name_to_atom("invalid")returns{:error, :invalid_permission_set}Edge Cases:
all_permission_sets/0Test File:
test/mv/authorization/permission_sets_test.exs