security

Solid

Enforce Elixir/Phoenix security — auth, OAuth, sessions, CSRF, XSS, SQL injection, input validation, secrets. Use when editing auth files, login flows, RBAC, or API keys.

API & Backend 437 stars 25 forks Updated today MIT

Install

View on GitHub

Quality Score: 97/100

Stars 20%
88
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Elixir/Phoenix Security Reference Quick reference for security patterns in Elixir/Phoenix. ## Iron Laws — Never Violate These 1. **VALIDATE AT BOUNDARIES** — Never trust client input. All data through changesets 2. **NEVER INTERPOLATE USER INPUT** — Use Ecto's `^` operator, never string interpolation 3. **NO String.to_atom WITH USER INPUT** — Atom exhaustion DoS. Use `to_existing_atom/1` 4. **AUTHORIZE EVERYWHERE** — Check in contexts AND re-validate in LiveView events 5. **ESCAPE BY DEFAULT** — Never use `raw/1` with untrusted content 6. **SECRETS NEVER IN CODE** ��� All secrets in `runtime.exs` from env vars ## Quick Patterns ### Timing-Safe Authentication ```elixir def authenticate(email, password) do user = Repo.get_by(User, email: email) cond do user && Argon2.verify_pass(password, user.hashed_password) -> {:ok, user} user -> {:error, :invalid_credentials} true -> Argon2.no_user_verify() # Timing attack prevention {:error, :invalid_credentials} end end ``` ### LiveView Authorization (CRITICAL) ```elixir # RE-AUTHORIZE IN EVERY EVENT HANDLER def handle_event("delete", %{"id" => id}, socket) do post = Blog.get_post!(id) # Don't trust that mount authorized this action! with :ok <- Bodyguard.permit(Blog, :delete_post, socket.assigns.current_user, post) do Blog.delete_post(post) {:noreply, stream_delete(socket, :posts, post)} else _ -> {:noreply, put_flash(socket, :error, "Unauthorized")} end end ```...

Details

Author
oliver-kriska
Repository
oliver-kriska/claude-elixir-phoenix
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category