Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Use embed-friendly secure headers for HelpScout integration endpoints (#5817)
Adrian Gruntkowski559c07d2d2a0
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex 31f2f72e54..8fc00df3f8 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -40,6 +40,17 @@ defmodule PlausibleWeb.Router doplug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}end+ on_ee do+ pipeline :helpscout do+ plug :accepts, ["html"]+ plug :fetch_session+ plug PlausibleWeb.Plugs.SecureEmbedHeaders+ plug PlausibleWeb.Plugs.NoRobots+ plug PlausibleWeb.AuthPlug+ plug :put_root_layout, html: {PlausibleWeb.LayoutView, :app}+ end+ end+pipeline :csrf doplug :protect_from_forgeryend@@ -503,6 +514,14 @@ defmodule PlausibleWeb.Router doget "/logout", AuthController, :logoutget "/team/select", AuthController, :select_teamend++ scope "/", PlausibleWeb do+ pipe_through [:helpscout, :csrf]++ get "/helpscout/callback", HelpScoutController, :callback+ get "/helpscout/show", HelpScoutController, :show+ get "/helpscout/search", HelpScoutController, :search+ endendscope "/", PlausibleWeb do@@ -517,12 +536,6 @@ defmodule PlausibleWeb.Router doget "/auth/google/callback", AuthController, :google_auth_callback- on_ee do- get "/helpscout/callback", HelpScoutController, :callback- get "/helpscout/show", HelpScoutController, :show- get "/helpscout/search", HelpScoutController, :search- end-get "/", PageController, :indexget "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_previewdiff --git a/test/plausible_web/controllers/help_scout_controller_test.exs b/test/plausible_web/controllers/help_scout_controller_test.exsindex 5a2eb37b5e..28485048ed 100644--- a/test/plausible_web/controllers/help_scout_controller_test.exs+++ b/test/plausible_web/controllers/help_scout_controller_test.exs@@ -50,6 +50,8 @@ defmodule PlausibleWeb.HelpScoutControllerTest do"/helpscout/callback?conversation-id=123&customer-id=500&X-HelpScout-Signature=#{signature}")+ assert [] = Plug.Conn.get_resp_header(conn, "content-security-policy")+assert html_response(conn, 200) =~Routes.customer_support_user_path(PlausibleWeb.Endpoint, :show, user.id)end