From f050fb0eeafffab20ba5519aa7b2894de14c1d1b Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 3 Jan 2026 15:53:18 -0600 Subject: [PATCH] Enable LiveDashboard at /dashboard with authentication LiveDashboard is now available at /dashboard in all environments and requires user authentication to access --- lib/towerops_web/router.ex | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/towerops_web/router.ex b/lib/towerops_web/router.ex index f4ea120a..5b6719b7 100644 --- a/lib/towerops_web/router.ex +++ b/lib/towerops_web/router.ex @@ -1,6 +1,7 @@ defmodule ToweropsWeb.Router do use ToweropsWeb, :router + import Phoenix.LiveDashboard.Router import ToweropsWeb.UserAuth pipeline :browser do @@ -28,19 +29,18 @@ defmodule ToweropsWeb.Router do # pipe_through :api # end - # Enable LiveDashboard and Swoosh mailbox preview in development - if Application.compile_env(:towerops, :dev_routes) do - # If you want to use the LiveDashboard in production, you should put - # it behind authentication and allow only admins to access it. - # If your application does not have an admins-only section yet, - # you can use Plug.BasicAuth to set up some basic authentication - # as long as you are also using SSL (which you should anyway). - import Phoenix.LiveDashboard.Router + # Enable LiveDashboard in production with authentication + scope "/dashboard" do + pipe_through [:browser, :require_authenticated_user] + live_dashboard "/", metrics: ToweropsWeb.Telemetry + end + + # Enable Swoosh mailbox preview in development + if Application.compile_env(:towerops, :dev_routes) do scope "/dev" do pipe_through :browser - live_dashboard "/dashboard", metrics: ToweropsWeb.Telemetry forward "/mailbox", Plug.Swoosh.MailboxPreview end end