Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Mute automated login attempts (#5658)

Adam Rutkowskiac739da69452
diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.ex
index c4fd3e5994..41f39bbfcc 100644
--- a/lib/plausible_web/controllers/auth_controller.ex
+++ b/lib/plausible_web/controllers/auth_controller.ex
@@ -336,6 +336,10 @@ defmodule PlausibleWeb.AuthController do
end
end
+ def login(conn, _params) do
+ conn |> send_resp(403, "") |> halt()
+ end
+
defp accept_team_invitation(conn, team_identifier, user, params \\ [])
defp accept_team_invitation(conn, no_identifier, _user, params)
diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exs
index c05e48542c..547630b11d 100644
--- a/test/plausible_web/controllers/auth_controller_test.exs
+++ b/test/plausible_web/controllers/auth_controller_test.exs
@@ -706,6 +706,36 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(response, 429) =~ "Too many login attempts"
end
+
+ test "malicious automated logins", %{conn: conn1} do
+ conn =
+ post(conn1, "/login", %{
+ "g-recaptcha-response" => "NwBMkEWbh",
+ "user[email]" => "[email protected]",
+ "user[name]" => "CJCtGVXVgfORdNN",
+ "user[password]" => "[Filtered]",
+ "user[password_confirmation]" => "[Filtered]",
+ "user[register_action]" => "register_form"
+ })
+
+ assert response(conn, 403)
+
+ conn =
+ conn1
+ |> put_req_header("content-type", "application/json")
+ |> post("/login", """
+ {
+ "g-recaptcha-response": "NwBMkEWbh",
+ "user[email]": "[email protected]",
+ "user[name]": "CJCtGVXVgfORdNN",
+ "user[password]": "[Filtered]",
+ "user[password_confirmation]": "[Filtered]",
+ "user[register_action]": "register_form"
+ }
+ """)
+
+ assert response(conn, 403)
+ end
end
describe "GET /password/request-reset" do