phoenix-authorization-patterns
Installation
SKILL.md
Phoenix Authorization Patterns
RULES — Follow these with no exceptions
- Always authorize on the server in event handlers — never rely on UI-only checks
- Verify resource ownership by comparing
current_scope.user.idagainst the resource'suser_id— never trust client-sent user IDs - Use policy modules for complex authorization — don't inline permission checks in LiveViews or controllers
- Add
data-confirmattribute for destructive UI actions — client-side confirmation before server round-trip - Test both authorized and unauthorized paths — every
handle_eventthat mutates data needs an authz test - Scope queries to the current user in contexts —
where(user_id: ^user_id)prevents IDOR vulnerabilities
Authorization Workflow for a New Resource
Follow these steps in order when adding authorization to any new resource: