Curated library of 38 atomic skills, 7 personas, and 1 orchestrator for Elixir and Phoenix development. Organized by category: fundamentals, phoenix, database, testing, auth, infrastructure, quality, security, integrations, tooling, frameworks, personas, and orchestration. Covers core Elixir patterns, Phoenix LiveView, Ecto, OTP, Oban, testing, security, deployment, real-time, and modern tooling (Req, Swoosh, Cachex, Broadway, Ash).
73
91%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
current_scope.user.id against the resource's user_id — never trust client-sent user IDsdata-confirm attribute for destructive UI actions — client-side confirmation before server round-triphandle_event that mutates data needs an authz testwhere(user_id: ^user_id) prevents IDOR vulnerabilitiesFollow these steps in order when adding authorization to any new resource:
user_id so unauthorized data is never returnedview, edit, delete, etc.) before wiring up any LiveViewPolicy.authorize/3 or compare current_scope.user.id against the resource's user_id in every handle_event that mutates dataValidation checkpoints:
{:error, :unauthorized} ✓handle_event has a corresponding unauthorized-path test ✓defmodule MyAppWeb.PostLive.Show do
use MyAppWeb, :live_view
@impl true
def handle_event("delete", _params, socket) do
post = socket.assigns.post
if socket.assigns.current_scope.user.id == post.user_id do
{:ok, _} = Blog.delete_post(post)
{:noreply, push_navigate(socket, to: ~p"/posts")}
else
{:noreply, put_flash(socket, :error, "Not authorized")}
end
end
enddefmodule MyApp.Blog do
import Ecto.Query
# Scoped — only returns posts owned by this user
def list_user_posts(%Scope{user: user}) do
Post
|> where(user_id: ^user.id)
|> order_by(desc: :inserted_at)
|> Repo.all()
end
# Scoped get — returns nil if not owned by user
def get_user_post(%Scope{user: user}, id) do
Post
|> where(user_id: ^user.id)
|> Repo.get(id)
end
# Scoped update — only updates if owned
def update_user_post(%Scope{user: user}, %Post{} = post, attrs) do
if post.user_id == user.id do
post |> Post.changeset(attrs) |> Repo.update()
else
{:error, :unauthorized}
end
end
endFor complex permissions (roles, teams, org-level access):
defmodule MyApp.Policy do
alias MyApp.Accounts.User
alias MyApp.Blog.Post
def authorize(%User{role: :admin}, _action, _resource), do: :ok
def authorize(%User{id: user_id}, :edit, %Post{user_id: user_id}), do: :ok
def authorize(%User{id: user_id}, :delete, %Post{user_id: user_id}), do: :ok
def authorize(%User{}, :view, %Post{published: true}), do: :ok
def authorize(_user, _action, _resource), do: {:error, :unauthorized}
end
# Usage in LiveView
case Policy.authorize(user, :delete, post) do
:ok -> {:ok, _} = Blog.delete_post(post)
{:error, :unauthorized} -> put_flash(socket, :error, "Not authorized")
enddescribe "authorization" do
test "owner can delete their post", %{conn: conn} do
user = user_fixture()
post = post_fixture(user_id: user.id)
conn = log_in_user(conn, user)
{:ok, lv, _html} = live(conn, ~p"/posts/#{post}")
lv |> element("button", "Delete") |> render_click()
assert_redirect(lv, ~p"/posts")
end
test "non-owner cannot delete post", %{conn: conn} do
owner = user_fixture()
other_user = user_fixture()
post = post_fixture(user_id: owner.id)
conn = log_in_user(conn, other_user)
{:ok, lv, _html} = live(conn, ~p"/posts/#{post}")
refute render(lv) =~ "Delete"
assert render_click(lv, "delete") =~ "Not authorized"
end
end| Skill | Purpose |
|---|---|
| phoenix-liveview-auth | Authentication (who you are) |
| phoenix-scopes | Phoenix 1.8+ Scope-based auth |
| testing-essentials | Testing patterns |
| security-essentials | Broader security best practices |
| Predecessor | This Skill | Successor |
|---|---|---|
| phoenix-liveview-essentials | phoenix-authorization-patterns | security-essentials |