EnsureHostMatchesPlug: Remove match against default scheme port

Checking against the default port of the Endpoint URL scheme is
redundant as normal instances will have the combination https/443
by default created by pleroma.instance gen, Tor-only instances should
have combination http/80 and local testing instances httt/XXXX.

The default scheme port doesn't add anything usefull in these configs.
This commit is contained in:
Phantasm 2026-05-12 23:31:55 +02:00
commit 6f415cf3fc
No known key found for this signature in database
GPG key ID: 2669E588BCC634C8
2 changed files with 7 additions and 39 deletions

View file

@ -8,7 +8,6 @@ defmodule Pleroma.Web.Plugs.EnsureHostMatchesPlugTest do
alias Pleroma.Web.Endpoint
alias Pleroma.Web.Plugs.EnsureHostMatchesPlug
import Mock
import Plug.Conn
import Tesla.Mock
@ -105,33 +104,7 @@ defmodule Pleroma.Web.Plugs.EnsureHostMatchesPlugTest do
assert Map.get(conn.assigns, :valid_host_header, nil)
end
test "it works for Host header with port as 80", %{conn: conn} do
endpoint = URI.parse(Endpoint.url())
conn =
conn
|> set_host("#{endpoint.host}:80")
|> EnsureHostMatchesPlug.call(%{})
assert conn.halted == false
assert Map.get(conn.assigns, :valid_host_header, nil)
end
test "it works for Host header with port as 443", %{conn: conn} do
with_mock Pleroma.Web.Endpoint, url: fn -> "https://localhost:4001" end do
endpoint = URI.parse(Endpoint.url())
conn =
conn
|> set_host("#{endpoint.host}:443")
|> EnsureHostMatchesPlug.call(%{})
assert conn.halted == false
assert Map.get(conn.assigns, :valid_host_header, nil)
end
end
test "it works for Host header with port as same as Endpoint (no reverse proxy config)", %{
test "it works for Host header with port same as Endpoint", %{
conn: conn
} do
endpoint = URI.parse(Endpoint.url())