Merge branch 'webfinger-actual-fix' into 'develop'
Fix WebFinger for split-domain setups See merge request pleroma/pleroma!4405
This commit is contained in:
commit
d19b992417
4 changed files with 142 additions and 32 deletions
|
|
@ -93,7 +93,7 @@ defmodule Pleroma.Web.WebFingerTest do
|
|||
{:ok, _data} = WebFinger.finger(user)
|
||||
end
|
||||
|
||||
test "it work for AP-only user" do
|
||||
test "it works for AP-only user" do
|
||||
user = "kpherox@mstdn.jp"
|
||||
|
||||
{:ok, data} = WebFinger.finger(user)
|
||||
|
|
@ -224,24 +224,84 @@ defmodule Pleroma.Web.WebFingerTest do
|
|||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/gleasonator.com_host_meta")
|
||||
}}
|
||||
|
||||
%{url: "https://whitehouse.gov/.well-known/webfinger?resource=acct:trump@whitehouse.gov"} ->
|
||||
{:ok, %Tesla.Env{status: 404}}
|
||||
end)
|
||||
|
||||
{:error, _data} = WebFinger.finger("alex@gleasonator.com")
|
||||
end
|
||||
end
|
||||
|
||||
test "prevents forgeries" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: "https://fba.ryona.agency/.well-known/webfinger?resource=acct:graf@fba.ryona.agency"} ->
|
||||
fake_webfinger =
|
||||
File.read!("test/fixtures/webfinger/graf-imposter-webfinger.json") |> Jason.decode!()
|
||||
test "prevents forgeries" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{
|
||||
url:
|
||||
"https://fba.ryona.agency/.well-known/webfinger?resource=acct:graf@fba.ryona.agency"
|
||||
} ->
|
||||
fake_webfinger =
|
||||
File.read!("test/fixtures/webfinger/graf-imposter-webfinger.json") |> Jason.decode!()
|
||||
|
||||
Tesla.Mock.json(fake_webfinger)
|
||||
Tesla.Mock.json(fake_webfinger)
|
||||
|
||||
%{url: "https://fba.ryona.agency/.well-known/host-meta"} ->
|
||||
{:ok, %Tesla.Env{status: 404}}
|
||||
end)
|
||||
%{url: url}
|
||||
when url in [
|
||||
"https://poa.st/.well-known/webfinger?resource=acct:graf@poa.st",
|
||||
"https://fba.ryona.agency/.well-known/host-meta"
|
||||
] ->
|
||||
{:ok, %Tesla.Env{status: 404}}
|
||||
end)
|
||||
|
||||
assert {:error, _} = WebFinger.finger("graf@fba.ryona.agency")
|
||||
assert {:error, _} = WebFinger.finger("graf@fba.ryona.agency")
|
||||
end
|
||||
|
||||
test "prevents forgeries even when the spoofed subject exists on the target domain" do
|
||||
Tesla.Mock.mock(fn
|
||||
%{url: url}
|
||||
when url in [
|
||||
"https://attacker.example/.well-known/host-meta",
|
||||
"https://victim.example/.well-known/host-meta"
|
||||
] ->
|
||||
{:ok, %Tesla.Env{status: 404}}
|
||||
|
||||
%{
|
||||
url:
|
||||
"https://attacker.example/.well-known/webfinger?resource=acct:alice@attacker.example"
|
||||
} ->
|
||||
Tesla.Mock.json(%{
|
||||
"subject" => "acct:alice@victim.example",
|
||||
"links" => [
|
||||
%{
|
||||
"rel" => "self",
|
||||
"type" => "application/activity+json",
|
||||
"href" => "https://attacker.example/users/alice"
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
%{url: "https://victim.example/.well-known/webfinger?resource=acct:alice@victim.example"} ->
|
||||
Tesla.Mock.json(%{
|
||||
"subject" => "acct:alice@victim.example",
|
||||
"links" => [
|
||||
%{
|
||||
"rel" => "self",
|
||||
"type" => "application/activity+json",
|
||||
"href" => "https://victim.example/users/alice"
|
||||
}
|
||||
]
|
||||
})
|
||||
end)
|
||||
|
||||
assert {:error, _} = WebFinger.finger("alice@attacker.example")
|
||||
end
|
||||
|
||||
test "works for correctly set up split-domain instances implementing host-meta redirect" do
|
||||
{:ok, _data} = WebFinger.finger("a@pleroma.example")
|
||||
{:ok, _data} = WebFinger.finger("a@sub.pleroma.example")
|
||||
end
|
||||
|
||||
test "works for correctly set up split-domain instances without host-meta redirect" do
|
||||
{:ok, _data} = WebFinger.finger("a@mastodon.example")
|
||||
{:ok, _data} = WebFinger.finger("a@sub.mastodon.example")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue