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
Remove Firewall plug; redundant at infra level (#2730)
Adam4b21b4e6d04a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cd29b4264d..763b288b3f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file.- Device type is now determined from the User-Agent instead of window.innerWidth plausible/analytics#2711### Removed+- Remove Firewall plug and `IP_BLOCKLIST` environment variable- Remove the ability to collapse the main graph plausible/analytics#2627## v1.5.1 - 2022-12-06diff --git a/config/runtime.exs b/config/runtime.exsindex bbbb8d3ee7..5cc3882baa 100644--- a/config/runtime.exs+++ b/config/runtime.exs@@ -356,12 +356,6 @@ case mailer_adapter do"""end-config :plausible, PlausibleWeb.Firewall,- blocklist:- get_var_from_path_or_env(config_dir, "IP_BLOCKLIST", "")- |> String.split(",")- |> Enum.map(&String.trim/1)-base_cron = [# Daily at midnight{"0 0 * * *", Plausible.Workers.RotateSalts},diff --git a/lib/plausible_web/plugs/firewall.ex b/lib/plausible_web/plugs/firewall.exdeleted file mode 100644index 266a109283..0000000000--- a/lib/plausible_web/plugs/firewall.ex+++ /dev/null@@ -1,17 +0,0 @@-defmodule PlausibleWeb.Firewall do- import Plug.Conn-- def init(opts) do- opts- end-- def call(conn, _opts) do- blocklist = Keyword.fetch!(Application.get_env(:plausible, __MODULE__), :blocklist)-- if PlausibleWeb.RemoteIp.get(conn) in blocklist do- send_resp(conn, 404, "Not found") |> halt- else- conn- end- end-enddiff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex fa9839e869..cd7e66e776 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -4,7 +4,6 @@ defmodule PlausibleWeb.Router dopipeline :browser doplug :accepts, ["html"]- plug PlausibleWeb.Firewallplug :fetch_sessionplug :fetch_flashplug :put_secure_browser_headers@@ -25,21 +24,18 @@ defmodule PlausibleWeb.Router dopipeline :api doplug :accepts, ["json"]- plug PlausibleWeb.Firewallplug :fetch_sessionplug PlausibleWeb.AuthPlugendpipeline :internal_stats_api doplug :accepts, ["json"]- plug PlausibleWeb.Firewallplug :fetch_sessionplug PlausibleWeb.AuthorizeSiteAccessendpipeline :public_api doplug :accepts, ["json"]- plug PlausibleWeb.Firewallendpipeline :flags dodiff --git a/test/plausible_web/plugs/firewall_test.exs b/test/plausible_web/plugs/firewall_test.exsdeleted file mode 100644index ef73547eb0..0000000000--- a/test/plausible_web/plugs/firewall_test.exs+++ /dev/null@@ -1,29 +0,0 @@-defmodule PlausibleWeb.FirewallTest do- use Plausible.DataCase- use Plug.Test- alias PlausibleWeb.Firewall-- @allowed_ip "127.0.0.1"- @blocked_ip "127.0.0.2"- @opts [blocklist: [@blocked_ip]]-- setup_patch_env(PlausibleWeb.Firewall, blocklist: [@blocked_ip])-- test "ignores request if IP is allowed" do- conn =- conn(:get, "/")- |> put_req_header("x-forwarded-for", @allowed_ip)- |> Firewall.call(@opts)-- assert conn.status == nil- end-- test "responds with 404 if IP is blocked" do- conn =- conn(:get, "/")- |> put_req_header("x-forwarded-for", @blocked_ip)- |> Firewall.call(@opts)-- assert conn.status == 404- end-end