Fix WebFinger for split-domain setups #1032

Open
mkljczk wants to merge 6 commits from mkljczk/akkoma:webfinger-actual-fix into develop
Contributor

Currently, running a webfinger query like WebFinger.finger("hswaw@social.hackerspace.pl") fails in the validate_webfinger/2 function due to a hostname mismatch.

As a result, when update_nickname_on_user_fetch is enabled (which is the default), fetching and updating a user — eg. via Pleroma.Web.ActivityPub.ActivityPub.generate_nickname/1 — causes the stored nickname to change to include the domain name from actor's AP url.

The issue doesn't happen when resolving addresses of instances having a /.well-known/host-meta redirect between domains. However, Mastodon documentation doesn't instruct admins to configure such a redirect.

My PR resolves this issue, while keeping the existing spoofing prevention working (it worked before a security fix introduced a regression which I only partially fixed).

Currently, running a webfinger query like `WebFinger.finger("hswaw@social.hackerspace.pl")` fails in the `validate_webfinger/2` function due to a hostname mismatch. As a result, when `update_nickname_on_user_fetch` is enabled (which is the default), fetching and updating a user — eg. via `Pleroma.Web.ActivityPub.ActivityPub.generate_nickname/1` — causes the stored nickname to change to include the domain name from actor's AP url. The issue doesn't happen when resolving addresses of instances having a `/.well-known/host-meta` redirect between domains. However, Mastodon documentation [doesn't instruct admins](https://docs.joinmastodon.org/admin/config/#web_domain) to configure such a redirect. My PR resolves this issue, while keeping the existing spoofing prevention working (it worked before [a security fix](https://git.pleroma.social/pleroma/pleroma/-/merge_requests/4114) introduced a regression which I [only partially fixed](https://git.pleroma.social/pleroma/pleroma/-/merge_requests/4116)).
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
Update tests, make the mastodon subdomain example not have the /.well-known/host-meta redirect, as the docs don't include it
Some checks are pending
ci/woodpecker/pr/test/1 Pipeline is pending approval
ci/woodpecker/pr/test/2 Pipeline is pending approval
5a6f0408c8
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
WebFinger: Tighten the requirements.
Some checks are pending
ci/woodpecker/pr/test/1 Pipeline is pending approval
ci/woodpecker/pr/test/2 Pipeline is pending approval
221d995d51
floatingghost left a comment
Owner

i'm not seeing much wrong here, just one thing to potentially change up

i'm not seeing much wrong here, just one thing to potentially change up
@ -185,2 +185,4 @@
body: File.read!("test/fixtures/tesla_mock/bad.com_host_meta")
}}
%{url: "https://whitehouse.gov/.well-known/webfinger?resource=acct:trump@whitehouse.gov"} ->

this is a very specific gripe but we should probably avoid having outright irl politics in our test strings

this is a very specific gripe but we should probably avoid having outright irl politics in our test strings
Author
Contributor

Thanks, accidentally merged this from Pleroma, this mock was not even used

Thanks, accidentally merged this from Pleroma, this mock was not even used
Remove unused mock
Some checks are pending
ci/woodpecker/pr/test/1 Pipeline is pending approval
ci/woodpecker/pr/test/2 Pipeline is pending approval
b9c72f2d4d
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
Some checks are pending
ci/woodpecker/pr/test/1 Pipeline is pending approval
ci/woodpecker/pr/test/2 Pipeline is pending approval
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u webfinger-actual-fix:mkljczk-webfinger-actual-fix
git switch mkljczk-webfinger-actual-fix
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AkkomaGang/akkoma!1032
No description provided.