phoenix-liveview-auth

Apply on_mount-based authentication to secure Phoenix LiveView sessions.

149|15|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phoenix-liveview-auth
Source: https://github.com/j-morgan6/elixir-phoenix-guide/tree/main/skills/phoenix-liveview-auth
Command: npx skills add https://github.com/j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Secure LiveView sessions by consistently applying on_mount-based authentication across Phoenix applications to centralize access control and reduce scattered auth checks.

Core Features & Use Cases

  • Centralized on_mount authentication for LiveView modules
  • mount_current_scope pattern to extract user scope from session
  • Resolver for import conflicts and safe template access via assigns bracket syntax
  • Router integration with live_session groups to apply auth to entire sections

Quick Start

Add a UserAuth on_mount handler and apply it through live_session to protect LiveView routes.

Frequently Asked Questions about phoenix-liveview-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add authentication to Phoenix LiveView routes?

Add authentication to Phoenix LiveView by applying on_mount callbacks through live_session groups in your router, centralizing access control and redirecting unauthenticated users from protected sections like dashboards and admin areas.

What is the mount_current_scope pattern in Phoenix LiveView?

The mount_current_scope pattern extracts the user scope from the session during the on_mount callback, allowing your LiveView modules to securely access the authenticated user data without scattering auth checks across individual components.

How do I resolve import conflicts when adding authentication to LiveView?

Resolve import conflicts during LiveView authentication by using a dedicated resolver and accessing template variables safely through assigns bracket syntax, preventing naming collisions between your auth modules and existing application code.

Can I use live_session groups to protect multiple Phoenix LiveView routes?

Yes, you can use live_session groups in the Phoenix router to apply on_mount authentication handlers to entire sections of your application, securing multiple LiveView routes like forms and dashboards with a single centralized configuration.

Why do I need on_mount for LiveView session security?

You need on_mount for LiveView session security because it intercepts connections at the router level, ensuring consistent access control and user scope extraction before any module mounts, reducing scattered and vulnerable auth checks.

Does this approach work for admin areas built with Phoenix LiveView?

Yes, this on_mount authentication approach works for admin areas built with Phoenix LiveView by applying session-based access control and redirects through live_session groups, ensuring only authenticated users access protected administrative sections.