User Resource Policies closes #363 #364

Merged
moritz merged 20 commits from feature/363_user_policies into main 2026-01-22 23:24:38 +01:00
Owner

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

What has been changed?

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

## Description of the implemented changes The changes were: - [ ] Bugfixing - [x] New Feature - [ ] Breaking Change - [ ] Refactoring <!--- Describe the goal of the PR in a few words --> ## What has been changed? <!--- List the things you changed --> ## Definition of Done ### Code Quality - [x] No new technical depths - [x] Linting passed - [x] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [x] Tests for new code are written - [x] All tests pass - [ ] axe-core dev tools show no critical or major issues ## Additional Notes <!--- Add any additional information for the reviewers here -->
moritz added this to the Accounts & Logins milestone 2026-01-22 19:21:13 +01:00
moritz self-assigned this 2026-01-22 19:21:13 +01:00
moritz added 3 commits 2026-01-22 19:21:15 +01:00
Implement bypass for READ + HasPermission for UPDATE pattern
Extend HasPermission check to support User resource scope :own
31 tests covering all 4 permission sets and bypass scenarios
Update HasPermission tests to expect false for scope :own without record
docs(auth): document User policies and bypass pattern
All checks were successful
continuous-integration/drone/push Build is passing
5506b5b2dc
Add bypass vs HasPermission pattern documentation
Update architecture and implementation plan docs
moritz added 9 commits 2026-01-22 21:37:06 +01:00
Add Mix.env() check to match?/3 for defense in depth.
Document NoActor pattern in CODE_GUIDELINES.md.
Extract ash_resource? helper to reduce nesting depth.
Add ensure_role_loaded fallback for unloaded actor roles.
Add explicit comments explaining why all permission sets
grant User.update with scope :own for password changes.
Move why explanations to documentation files.
Keep policy comments concise and focused.
Add ensure_user_role_loaded to global live_view quote block.
Remove redundant on_mount calls from individual LiveViews.
Fix Credo parsing error by removing for comprehension.
Duplicate tests for own_data, read_only, normal_user sets.
Encapsulate two-tier policy pattern (bypass + HasPermission).
Promote consistency across resource policy definitions.
Enforce User.update :own across all permission sets.
Verify READ bypass + UPDATE HasPermission pattern.
Update documentation for User credentials strategy
All checks were successful
continuous-integration/drone/push Build is passing
811a276d92
Clarify that User.update :own is handled by HasPermission.
Fix file path references from lib/mv/accounts to lib/accounts.
moritz added 3 commits 2026-01-22 22:46:23 +01:00
Use Application.compile_env for release-safety.
Config only set in test.exs (defaults to false).
Consolidate role loading logic from HasPermission and LiveHelpers.
Use Ash.Resource.Info.resource? for reliable Ash detection.
Remove unused PolicyHelpers macro and PolicyConsistency test
All checks were successful
continuous-integration/drone/push Build is passing
e60bb6926f
Dead code - macro was never used in codebase.
PolicyConsistency test will be replaced with better implementation.
moritz added 3 commits 2026-01-22 23:05:24 +01:00
SECURITY: Skip authorization for role loading to avoid circular dependency.
Actor loads their OWN role, needed for authorization itself.
Documented why this is safe.
Test removed - JWT flow tested via AshAuthentication integration.
Direct test would require JWT mocking without value.
Update CODE_GUIDELINES for Application.compile_env pattern
All checks were successful
continuous-integration/drone/push Build is passing
f32324d942
Replace Mix.env example with config-based approach.
Remove outdated runtime guard documentation.
moritz added 2 commits 2026-01-22 23:18:36 +01:00
Remove mentions of runtime guards - only compile-time config is used.
Clarify that production safety comes from config defaults.
Restrict Actor.ensure_loaded to Mv.Accounts.User only
All checks were successful
continuous-integration/drone/push Build is passing
427608578f
Pattern match on %Mv.Accounts.User{} instead of generic actor.
Clearer intention, prevents accidental authorization bypasses.
Non-User actors are returned as-is (no-op).
moritz merged commit 67b5d623cf into main 2026-01-22 23:24:38 +01:00
moritz deleted branch feature/363_user_policies 2026-01-22 23:24:39 +01:00
moritz modified the milestone from Accounts & Logins to We have different roles and permissions 2026-02-03 16:39:08 +01:00
Sign in to join this conversation.
No description provided.