Refactor Webfinger module, use XRD host-meta to find webfinger endpoint

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-04-09 10:19:25 +02:00
parent bd53bfc46b
commit b34958d3af
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
12 changed files with 442 additions and 117 deletions

View file

@ -654,7 +654,7 @@ defmodule Mobilizon.Federation.ActivityPub do
@spec make_actor_from_nickname(String.t()) :: {:ok, %Actor{}} | {:error, any()}
def make_actor_from_nickname(nickname) do
case WebFinger.finger(nickname) do
{:ok, %{"url" => url}} when not is_nil(url) ->
{:ok, url} when is_binary(url) ->
make_actor_from_url(url)
_e ->

View file

@ -159,7 +159,7 @@ defmodule Mobilizon.Federation.ActivityPub.Relay do
@spec finger_actor(String.t()) :: {:ok, String.t()} | {:error, String.t()}
defp finger_actor(nickname) do
case WebFinger.finger(nickname) do
{:ok, %{"url" => url}} when not is_nil(url) ->
{:ok, url} when is_binary(url) ->
{:ok, url}
_e ->

View file

@ -12,26 +12,37 @@ defmodule Mobilizon.Federation.WebFinger do
alias Mobilizon.Actors.Actor
alias Mobilizon.Federation.ActivityPub
alias Mobilizon.Federation.WebFinger.XmlBuilder
alias Mobilizon.Service.HTTP.WebfingerClient
alias Mobilizon.Service.HTTP.{HostMetaClient, WebfingerClient}
alias Mobilizon.Web.Endpoint
alias Mobilizon.Web.Router.Helpers, as: Routes
require Jason
require Logger
import SweetXml
def host_meta do
base_url = Endpoint.url()
%URI{host: host} = URI.parse(base_url)
{
:XRD,
%{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"},
{
:Link,
%{
rel: "lrdd",
type: "application/xrd+xml",
template: "#{base_url}/.well-known/webfinger?resource={uri}"
%{
xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0",
"xmlns:hm": "http://host-meta.net/ns/1.0"
},
[
{
:"hm:Host",
host
},
{
:Link,
%{
rel: "lrdd",
type: "application/jrd+json",
template: "#{base_url}/.well-known/webfinger?resource={uri}"
}
}
}
]
}
|> XmlBuilder.to_doc()
end
@ -56,29 +67,116 @@ defmodule Mobilizon.Federation.WebFinger do
end
@spec represent_actor(Actor.t()) :: struct()
def represent_actor(actor), do: represent_actor(actor, "JSON")
def represent_actor(%Actor{} = actor), do: represent_actor(actor, "JSON")
@spec represent_actor(Actor.t(), String.t()) :: struct()
def represent_actor(actor, "JSON") do
%{
"subject" => "acct:#{actor.preferred_username}@#{Endpoint.host()}",
"aliases" => [actor.url],
"links" => [
def represent_actor(%Actor{} = actor, "JSON") do
links =
[
%{"rel" => "self", "type" => "application/activity+json", "href" => actor.url},
%{
"rel" => "https://webfinger.net/rel/profile-page/",
"type" => "text/html",
"href" => actor.url
},
%{
"rel" => "http://ostatus.org/schema/1.0/subscribe",
"template" => "#{Routes.page_url(Endpoint, :interact, uri: nil)}{uri}"
}
]
|> maybe_add_avatar(actor)
|> maybe_add_profile_page(actor)
%{
"subject" => "acct:#{actor.preferred_username}@#{Endpoint.host()}",
"aliases" => [actor.url],
"links" => links
}
end
defp webfinger_from_json(doc) do
defp maybe_add_avatar(data, %Actor{avatar: avatar}) when not is_nil(avatar) do
data ++
[
%{
"rel" => "http://webfinger.net/rel/avatar",
"type" => avatar.content_type,
"href" => avatar.url
}
]
end
defp maybe_add_avatar(data, _actor), do: data
defp maybe_add_profile_page(data, %Actor{type: :Group, url: url}) do
data ++
[
%{
"rel" => "http://webfinger.net/rel/profile-page/",
"type" => "text/html",
"href" => url
}
]
end
defp maybe_add_profile_page(data, _actor), do: data
@doc """
Finger an actor to retreive it's ActivityPub ID/URL
Fetches the Extensible Resource Descriptor endpoint `/.well-known/host-meta` to find the Webfinger endpoint (usually `/.well-known/webfinger?resource=`) with `find_webfinger_endpoint/1` and then performs a Webfinger query to get the ActivityPub ID associated to an actor.
"""
@spec finger(String.t()) :: {:ok, String.t()} | {:error, atom()}
def finger(actor) do
actor = String.trim_leading(actor, "@")
with address when is_binary(address) <- apply_webfinger_endpoint(actor),
false <- address_invalid(address),
{:ok, %{body: body, status: code}} when code in 200..299 <-
WebfingerClient.get(address),
{:ok, %{"url" => url}} <- webfinger_from_json(body) do
{:ok, url}
else
e ->
Logger.debug("Couldn't finger #{actor}")
Logger.debug(inspect(e))
{:error, e}
end
end
@doc """
Fetches the Extensible Resource Descriptor endpoint `/.well-known/host-meta` to find the Webfinger endpoint (usually `/.well-known/webfinger?resource=`)
"""
@spec find_webfinger_endpoint(String.t()) :: String.t()
def find_webfinger_endpoint(domain) when is_binary(domain) do
with {:ok, %{body: body}} <- fetch_document("http://#{domain}/.well-known/host-meta"),
link_template <- find_link_from_template(body) do
{:ok, link_template}
end
end
@spec apply_webfinger_endpoint(String.t()) :: String.t() | {:error, :host_not_found}
defp apply_webfinger_endpoint(actor) do
with {:ok, domain} <- domain_from_federated_actor(actor) do
case find_webfinger_endpoint(domain) do
{:ok, link_template} ->
String.replace(link_template, "{uri}", "acct:#{actor}")
_ ->
"http://#{domain}/.well-known/webfinger?resource=acct:#{actor}"
end
end
end
@spec domain_from_federated_actor(String.t()) :: {:ok, String.t()} | {:error, :host_not_found}
defp domain_from_federated_actor(actor) do
case String.split(actor, "@") do
[_name, domain] ->
{:ok, domain}
_e ->
host = URI.parse(actor).host
if is_nil(host), do: {:error, :host_not_found}, else: {:ok, host}
end
end
@spec webfinger_from_json(map() | String.t()) ::
{:ok, map()} | {:error, :webfinger_information_not_json}
defp webfinger_from_json(doc) when is_map(doc) do
data =
Enum.reduce(doc["links"], %{"subject" => doc["subject"]}, fn link, data ->
case {link["type"], link["rel"]} do
@ -97,31 +195,26 @@ defmodule Mobilizon.Federation.WebFinger do
{:ok, data}
end
def finger(actor) do
actor = String.trim_leading(actor, "@")
defp webfinger_from_json(_doc), do: {:error, :webfinger_information_not_json}
domain =
case String.split(actor, "@") do
[_name, domain] ->
domain
@spec find_link_from_template(String.t()) :: String.t() | {:error, :link_not_found}
defp find_link_from_template(doc) do
with res when res in [nil, ""] <-
xpath(doc, ~x"//Link[@rel=\"lrdd\"][@type=\"application/json\"]/@template"s),
res when res in [nil, ""] <- xpath(doc, ~x"//Link[@rel=\"lrdd\"]/@template"s),
do: {:error, :link_not_found}
end
_e ->
URI.parse(actor).host
end
@spec fetch_document(String.t()) :: Tesla.Env.result()
defp fetch_document(endpoint) do
with {:error, err} <- HostMetaClient.get(endpoint), do: {:error, err}
end
address = "http://#{domain}/.well-known/webfinger?resource=acct:#{actor}"
Logger.debug(inspect(address))
with false <- is_nil(domain),
{:ok, %{body: body, status: code}} when code in 200..299 <-
WebfingerClient.get(address) do
webfinger_from_json(body)
else
e ->
Logger.debug(fn -> "Couldn't finger #{actor}" end)
Logger.debug(fn -> inspect(e) end)
{:error, e}
@spec address_invalid(String.t()) :: false | {:error, :invalid_address}
defp address_invalid(address) do
with %URI{host: host, scheme: scheme} <- URI.parse(address),
true <- is_nil(host) or is_nil(scheme) do
{:error, :invalid_address}
end
end
end

View file

@ -0,0 +1,24 @@
defmodule Mobilizon.Service.HTTP.HostMetaClient do
@moduledoc """
Tesla HTTP Basic Client
with XML middleware
"""
use Tesla
alias Mobilizon.Config
@default_opts [
recv_timeout: 20_000
]
adapter(Tesla.Adapter.Hackney, @default_opts)
plug(Tesla.Middleware.FollowRedirects)
plug(Tesla.Middleware.Timeout, timeout: 10_000)
plug(Tesla.Middleware.Headers, [
{"User-Agent", Config.instance_user_agent()},
{"Accept", "application/xrd+xml, application/xml, text/xml"}
])
end

View file

@ -144,6 +144,7 @@ defmodule Mobilizon.Mixfile do
{:slugger, "~> 0.3"},
{:sentry, "~> 8.0"},
{:html_entities, "~> 0.5"},
{:sweet_xml, "~> 0.6.6"},
# Dev and test dependencies
{:phoenix_live_reload, "~> 1.2", only: [:dev, :e2e]},
{:ex_machina, "~> 2.3", only: [:dev, :test]},

View file

@ -33,6 +33,7 @@
"elixir_feed_parser": {:hex, :elixir_feed_parser, "2.1.0", "bb96fb6422158dc7ad59de62ef211cc69d264acbbe63941a64a5dce97bbbc2e6", [:mix], [{:timex, "~> 3.4", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm", "2d3c62fe7b396ee3b73d7160bc8fadbd78bfe9597c98c7d79b3f1038d9cba28f"},
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"erlsom": {:hex, :erlsom, "1.5.0", "c5a5cdd0ee0e8dca62bcc4b13ff08da24fdefc16ccd8b25282a2fda2ba1be24a", [:rebar3], [], "hexpm", "55a9dbf9cfa77fcfc108bd8e2c4f9f784dea228a8f4b06ea10b684944946955a"},
"eternal": {:hex, :eternal, "1.2.2", "d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd", [:mix], [], "hexpm", "2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"},
"ex_cldr": {:hex, :ex_cldr, "2.20.0", "571a4b490c333809be59cc984a21be2deaab1db9e2418e323d5935aec8b1394a", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.15", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.13", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "06147e4a27be62e6fe92db14cf5048c645927bfc530aa1cc6af8c92d65e32427"},
"ex_cldr_calendars": {:hex, :ex_cldr_calendars, "1.13.0", "6bea6f3c54d74c0ed131dd17e1cff68e02b7053f24c2fac91f129e5221ff723a", [:mix], [{:calendar_interval, "~> 0.2", [hex: :calendar_interval, repo: "hexpm", optional: true]}, {:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.17", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_cldr_units, "~> 3.5", [hex: :ex_cldr_units, repo: "hexpm", optional: true]}, {:ex_doc, "~> 0.21", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d07ab6b2164b6a0861de6ecb600747aab61c94a0b9c001e36c2e0b731eeb567a"},
@ -122,6 +123,7 @@
"slugger": {:hex, :slugger, "0.3.0", "efc667ab99eee19a48913ccf3d038b1fb9f165fa4fbf093be898b8099e61b6ed", [:mix], [], "hexpm", "20d0ded0e712605d1eae6c5b4889581c3460d92623a930ddda91e0e609b5afba"},
"sobelow": {:hex, :sobelow, "0.11.1", "23438964486f8112b41e743bbfd402da3e5b296fdc9eacab29914b79c48916dd", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9897363a7eff96f4809304a90aad819e2ad5e5d24db547af502885146746a53c"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm", "2e1ec458f892ffa81f9f8386e3f35a1af6db7a7a37748a64478f13163a1f3573"},
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"tesla": {:hex, :tesla, "1.4.1", "ff855f1cac121e0d16281b49e8f066c4a0d89965f98864515713878cca849ac8", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "95f5de35922c8c4b3945bee7406f66eb680b0955232f78f5fb7e853aa1ce201a"},
"timex": {:hex, :timex, "3.7.5", "3eca56e23bfa4e0848f0b0a29a92fa20af251a975116c6d504966e8a90516dfd", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "a15608dca680f2ef663d71c95842c67f0af08a0f3b1d00e17bbd22872e2874e4"},

View file

@ -54,10 +54,7 @@ defmodule Mobilizon.Federation.WebFingerTest do
describe "fingering" do
test "a mastodon actor" do
use_cassette "webfinger/mastodon" do
res = %{
"subject" => "acct:" <> @mastodon_account,
"url" => "https://social.tcit.fr/users/#{@mastodon_account_username}"
}
res = "https://social.tcit.fr/users/#{@mastodon_account_username}"
assert {:ok, res} == WebFinger.finger(@mastodon_account)
end
@ -65,10 +62,7 @@ defmodule Mobilizon.Federation.WebFingerTest do
test "a pleroma actor" do
use_cassette "webfinger/pleroma" do
res = %{
"subject" => "acct:" <> @pleroma_account,
"url" => "https://pleroma.soykaf.com/users/#{@pleroma_account_username}"
}
res = "https://pleroma.soykaf.com/users/#{@pleroma_account_username}"
assert {:ok, res} == WebFinger.finger(@pleroma_account)
end
@ -76,10 +70,7 @@ defmodule Mobilizon.Federation.WebFingerTest do
test "a peertube actor" do
use_cassette "webfinger/peertube" do
res = %{
"subject" => "acct:" <> @peertube_account,
"url" => "https://framatube.org/accounts/#{@peertube_account_username}"
}
res = "https://framatube.org/accounts/#{@peertube_account_username}"
assert {:ok, res} == WebFinger.finger(@peertube_account)
end
@ -87,10 +78,7 @@ defmodule Mobilizon.Federation.WebFingerTest do
test "a friendica actor" do
use_cassette "webfinger/friendica" do
res = %{
"subject" => "acct:" <> @friendica_account,
"url" => "https://squeet.me/profile/#{@friendica_account_username}"
}
res = "https://squeet.me/profile/#{@friendica_account_username}"
assert {:ok, res} == WebFinger.finger(@friendica_account)
end

View file

@ -3,28 +3,81 @@
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "http://squeet.me/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>301 Moved Permanently</title>\n</head><body>\n<h1>Moved Permanently</h1>\n<p>The document has moved <a href=\"https://squeet.me/.well-known/host-meta\">here</a>.</p>\n<hr>\n<address>Apache/2.4.25 (Debian) Server at squeet.me Port 80</address>\n</body></html>\n",
"headers": {
"Date": "Fri, 09 Apr 2021 08:08:52 GMT",
"Server": "Apache/2.4.25 (Debian)",
"Location": "https://squeet.me/.well-known/host-meta",
"Content-Length": "322",
"Content-Type": "text/html; charset=iso-8859-1"
},
"status_code": 301,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "https://squeet.me/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<?xml version='1.0' encoding='UTF-8'?>\n<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'\n xmlns:hm='http://host-meta.net/xrd/1.0'>\n \n <hm:Host>squeet.me</hm:Host>\n \n <Link rel='lrdd' type='application/xrd+xml' template='https://squeet.me/xrd?uri={uri}' />\n <Link rel='lrdd' type='application/json' template='https://squeet.me/.well-known/webfinger?resource={uri}' />\n <Link rel='acct-mgmt' href='https://squeet.me/amcd' />\n <Link rel='http://services.mozilla.com/amcd/0.1' href='https://squeet.me/amcd' />\n\t<Link rel=\"http://oexchange.org/spec/0.8/rel/resident-target\" type=\"application/xrd+xml\" \n href=\"https://squeet.me/oexchange/xrd\" />\n\n <Property xmlns:mk=\"http://salmon-protocol.org/ns/magic-key\"\n type=\"http://salmon-protocol.org/ns/magic-key\"\n mk:key_id=\"1\">RSA.xlM2BNDH9hnO3W6vOUfJ5-tcUCaX-rx-kKydQd4ht21At4D4d1MrZ6nAQu7rnf5or9YZRhIpgvJvXBqWSo0zmALkUZUVrsS9WhH65I0qt24XNTPZJ1FdPDd7c1C131GzkymCbXBie3U2JaT7t0oimhWKUeA45gNfXk1T1l-7v4k.AQAB</Property>\n</XRD>\n",
"headers": {
"Date": "Fri, 09 Apr 2021 08:08:52 GMT",
"Server": "Apache/2.4.25 (Debian)",
"X-Account-Management-Status": "none",
"Vary": "Accept-Encoding",
"Transfer-Encoding": "chunked",
"Content-Type": "text/xml;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/json, application/activity+json, application/jrd+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
"recv_timeout": 20000
},
"request_body": "",
"url": "http://squeet.me/.well-known/webfinger?resource=acct:lain@squeet.me"
"url": "https://squeet.me/.well-known/webfinger?resource=acct:lain@squeet.me"
},
"response": {
"binary": false,
"body": "{\"subject\":\"acct:lain@squeet.me\",\"aliases\":[\"https:\\/\\/squeet.me\\/~lain\",\"https:\\/\\/squeet.me\\/profile\\/lain\"],\"links\":[{\"rel\":\"http:\\/\\/purl.org\\/macgirvin\\/dfrn\\/1.0\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"http:\\/\\/schemas.google.com\\/g\\/2010#updates-from\",\"type\":\"application\\/atom+xml\",\"href\":\"https:\\/\\/squeet.me\\/dfrn_poll\\/lain\"},{\"rel\":\"http:\\/\\/webfinger.net\\/rel\\/profile-page\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"self\",\"type\":\"application\\/activity+json\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"http:\\/\\/microformats.org\\/profile\\/hcard\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\\/hcard\\/lain\"},{\"rel\":\"http:\\/\\/portablecontacts.net\\/spec\\/1.0\",\"href\":\"https:\\/\\/squeet.me\\/poco\\/lain\"},{\"rel\":\"http:\\/\\/webfinger.net\\/rel\\/avatar\",\"type\":\"image\\/jpeg\",\"href\":\"https:\\/\\/squeet.me\\/photo\\/profile\\/301.jpg\"},{\"rel\":\"http:\\/\\/joindiaspora.com\\/seed_location\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\"},{\"rel\":\"salmon\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\"},{\"rel\":\"http:\\/\\/salmon-protocol.org\\/ns\\/salmon-replies\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\"},{\"rel\":\"http:\\/\\/salmon-protocol.org\\/ns\\/salmon-mention\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\\/mention\"},{\"rel\":\"http:\\/\\/ostatus.org\\/schema\\/1.0\\/subscribe\",\"template\":\"https:\\/\\/squeet.me\\/follow?url={uri}\"},{\"rel\":\"magic-public-key\",\"href\":\"data:application\\/magic-public-key,RSA.AMwa8FUs2fWEjX0xN7yRQgegQffhBpuKNC6fa5VNSVorFjGZhRrlPMn7TQOeihlc9lBz2OsHlIedbYn2uJ7yCs0.AQAB\"},{\"rel\":\"http:\\/\\/purl.org\\/openwebauth\\/v1\",\"type\":\"application\\/x-dfrn+json\",\"href\":\"https:\\/\\/squeet.me\\/owa\"}]}",
"body": "{\"subject\":\"acct:lain@squeet.me\",\"aliases\":[\"https:\\/\\/squeet.me\\/~lain\",\"https:\\/\\/squeet.me\\/profile\\/lain\"],\"links\":[{\"rel\":\"http:\\/\\/purl.org\\/macgirvin\\/dfrn\\/1.0\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"http:\\/\\/schemas.google.com\\/g\\/2010#updates-from\",\"type\":\"application\\/atom+xml\",\"href\":\"https:\\/\\/squeet.me\\/dfrn_poll\\/lain\"},{\"rel\":\"http:\\/\\/webfinger.net\\/rel\\/profile-page\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"self\",\"type\":\"application\\/activity+json\",\"href\":\"https:\\/\\/squeet.me\\/profile\\/lain\"},{\"rel\":\"http:\\/\\/microformats.org\\/profile\\/hcard\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\\/hcard\\/lain\"},{\"rel\":\"http:\\/\\/portablecontacts.net\\/spec\\/1.0\",\"href\":\"https:\\/\\/squeet.me\\/poco\\/lain\"},{\"rel\":\"http:\\/\\/webfinger.net\\/rel\\/avatar\",\"type\":\"image\\/jpeg\",\"href\":\"https:\\/\\/squeet.me\\/photo\\/abf2ee40bfcb044ac7fd1d143c82f63a-4.jpg?ts=1526641378\"},{\"rel\":\"http:\\/\\/joindiaspora.com\\/seed_location\",\"type\":\"text\\/html\",\"href\":\"https:\\/\\/squeet.me\"},{\"rel\":\"salmon\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\"},{\"rel\":\"http:\\/\\/salmon-protocol.org\\/ns\\/salmon-replies\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\"},{\"rel\":\"http:\\/\\/salmon-protocol.org\\/ns\\/salmon-mention\",\"href\":\"https:\\/\\/squeet.me\\/salmon\\/lain\\/mention\"},{\"rel\":\"http:\\/\\/ostatus.org\\/schema\\/1.0\\/subscribe\",\"template\":\"https:\\/\\/squeet.me\\/follow?url={uri}\"},{\"rel\":\"magic-public-key\",\"href\":\"data:application\\/magic-public-key,RSA.zBrwVSzZ9YSNfTE3vJFCB6BB9-EGm4o0Lp9rlU1JWisWMZmFGuU8yftNA56KGVz2UHPY6weUh51tifa4nvIKzQ.AQAB\"},{\"rel\":\"http:\\/\\/purl.org\\/openwebauth\\/v1\",\"type\":\"application\\/x-zot+json\",\"href\":\"https:\\/\\/squeet.me\\/owa\"}]}",
"headers": {
"Date": "Tue, 13 Nov 2018 11:11:09 GMT",
"Server": "Apache",
"Expires": "Thu, 19 Nov 1981 08:52:00 GMT",
"Cache-Control": "no-store, no-cache, must-revalidate",
"Pragma": "no-cache",
"Date": "Fri, 09 Apr 2021 08:08:52 GMT",
"Server": "Apache/2.4.25 (Debian)",
"X-Account-Management-Status": "none",
"Access-Control-Allow-Origin": "*",
"Set-Cookie": "PHPSESSID=330arcps63iok272c5hqdsfhp3; path=/; secure; HttpOnly",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"Transfer-Encoding": "chunked",
"Content-Type": "application/json; charset=utf-8"
},

View file

@ -3,26 +3,26 @@
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.0.0-rc.2-5-g6701e6a4",
"Accept": "application/json, application/activity+json, application/jrd+json"
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "http://social.tcit.fr/.well-known/webfinger?resource=acct:tcit@social.tcit.fr"
"url": "http://social.tcit.fr/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body>\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.19.3</center>\r\n</body>\r\n</html>\r\n",
"body": "<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.14.2</center>\r\n</body>\r\n</html>\r\n",
"headers": {
"Server": "nginx/1.19.3",
"Date": "Wed, 21 Oct 2020 09:07:41 GMT",
"Server": "nginx/1.14.2",
"Date": "Thu, 08 Apr 2021 18:59:56 GMT",
"Content-Type": "text/html",
"Content-Length": "169",
"Content-Length": "185",
"Connection": "keep-alive",
"Location": "https://social.tcit.fr/.well-known/webfinger?resource=acct:tcit@social.tcit.fr"
"Location": "https://social.tcit.fr/.well-known/host-meta"
},
"status_code": 301,
"type": "ok"
@ -32,7 +32,47 @@
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.0.0-rc.2-5-g6701e6a4",
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "https://social.tcit.fr/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\">\n <Link rel=\"lrdd\" template=\"https://social.tcit.fr/.well-known/webfinger?resource={uri}\"/>\n</XRD>\n",
"headers": {
"Date": "Thu, 08 Apr 2021 18:59:56 GMT",
"Content-Type": "application/xrd+xml; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
"Server": "Mastodon",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "same-origin",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
"X-Clacks-Overhead": "GNU Natalie Nguyen",
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=259200, public",
"ETag": "W/\"b397089bfee005b03360ba4435bb4aad\"",
"X-Request-Id": "41e837ba-21a6-4324-bda8-cac28a8d1778",
"X-Runtime": "0.004198",
"X-Cached": "MISS"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/json, application/activity+json, application/jrd+json"
},
"method": "get",
@ -46,7 +86,7 @@
"binary": false,
"body": "{\"subject\":\"acct:tcit@social.tcit.fr\",\"aliases\":[\"https://social.tcit.fr/@tcit\",\"https://social.tcit.fr/users/tcit\"],\"links\":[{\"rel\":\"http://webfinger.net/rel/profile-page\",\"type\":\"text/html\",\"href\":\"https://social.tcit.fr/@tcit\"},{\"rel\":\"self\",\"type\":\"application/activity+json\",\"href\":\"https://social.tcit.fr/users/tcit\"},{\"rel\":\"http://ostatus.org/schema/1.0/subscribe\",\"template\":\"https://social.tcit.fr/authorize_interaction?uri={uri}\"}]}",
"headers": {
"Date": "Wed, 21 Oct 2020 09:07:41 GMT",
"Date": "Thu, 08 Apr 2021 18:59:56 GMT",
"Content-Type": "application/jrd+json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
@ -60,8 +100,8 @@
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=259200, public",
"ETag": "W/\"37760e35c1537b8e02b6d4b4f9ebfe82\"",
"X-Request-Id": "429bb891-1033-498b-91bb-12835984223f",
"X-Runtime": "0.072046",
"X-Request-Id": "4c8384d6-d921-4ef6-8a18-1fcbf35ee6bc",
"X-Runtime": "0.009277",
"X-Cached": "MISS"
},
"status_code": 200,

View file

@ -3,33 +3,88 @@
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "http://framatube.org/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.14.2</center>\r\n</body>\r\n</html>\r\n",
"headers": {
"Server": "nginx/1.14.2",
"Date": "Thu, 08 Apr 2021 18:59:59 GMT",
"Content-Type": "text/html",
"Content-Length": "185",
"Connection": "keep-alive",
"Location": "https://framatube.org/.well-known/host-meta"
},
"status_code": 301,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "https://framatube.org/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\">\n <Link rel=\"lrdd\" type=\"application/xrd+xml\" template=\"https://framatube.org/.well-known/webfinger?resource={uri}\"/>\n</XRD>",
"headers": {
"Server": "nginx/1.14.2",
"Date": "Thu, 08 Apr 2021 18:59:59 GMT",
"Content-Type": "application/xml; charset=utf-8",
"Content-Length": "219",
"Connection": "keep-alive",
"Tk": "N",
"Access-Control-Allow-Origin": "*",
"ETag": "W/\"db-l6RCFQ8UK40DPZ9VQ8G/SKn3A64\""
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/json, application/activity+json, application/jrd+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
"recv_timeout": 20000
},
"request_body": "",
"url": "http://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org"
"url": "https://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org"
},
"response": {
"binary": false,
"body": "{\"subject\":\"acct:framasoft@framatube.org\",\"aliases\":[\"https://framatube.org/accounts/framasoft\"],\"links\":[{\"rel\":\"self\",\"type\":\"application/activity+json\",\"href\":\"https://framatube.org/accounts/framasoft\"}]}",
"body": "{\"subject\":\"acct:framasoft@framatube.org\",\"aliases\":[\"https://framatube.org/accounts/framasoft\"],\"links\":[{\"rel\":\"self\",\"type\":\"application/activity+json\",\"href\":\"https://framatube.org/accounts/framasoft\"},{\"rel\":\"http://ostatus.org/schema/1.0/subscribe\",\"template\":\"https://framatube.org/remote-interaction?uri={uri}\"}]}",
"headers": {
"Server": "nginx/1.10.3",
"Date": "Tue, 13 Nov 2018 11:11:11 GMT",
"Server": "nginx/1.14.2",
"Date": "Thu, 08 Apr 2021 18:59:59 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "207",
"Content-Length": "321",
"Connection": "keep-alive",
"X-DNS-Prefetch-Control": "off",
"X-Frame-Options": "DENY",
"X-Download-Options": "noopen",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Tk": "N",
"ETag": "W/\"cf-VoWlsif7OQ4xxqki7jRAnOPKRes\"",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
"X-Robots-Tag": "none"
"Access-Control-Allow-Origin": "*",
"ETag": "W/\"141-yxvvlAPayX5y2q2Yra8qYVtz4VU\""
},
"status_code": 200,
"type": "ok"

View file

@ -3,38 +3,107 @@
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "http://pleroma.soykaf.com/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body>\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.18.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n",
"headers": {
"Server": "nginx/1.18.0 (Ubuntu)",
"Date": "Thu, 08 Apr 2021 18:59:57 GMT",
"Content-Type": "text/html",
"Content-Length": "178",
"Connection": "keep-alive",
"Location": "https://pleroma.soykaf.com/.well-known/host-meta"
},
"status_code": 301,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/xrd+xml, application/xml, text/xml"
},
"method": "get",
"options": {
"recv_timeout": 20000
},
"request_body": "",
"url": "https://pleroma.soykaf.com/.well-known/host-meta"
},
"response": {
"binary": false,
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"><Link rel=\"lrdd\" template=\"https://pleroma.soykaf.com/.well-known/webfinger?resource={uri}\" type=\"application/xrd+xml\" /></XRD>",
"headers": {
"Server": "nginx/1.18.0 (Ubuntu)",
"Date": "Thu, 08 Apr 2021 18:59:57 GMT",
"Content-Type": "application/xrd+xml; charset=utf-8",
"Content-Length": "220",
"Connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"access-control-expose-headers": "Link,X-RateLimit-Reset,X-RateLimit-Limit,X-RateLimit-Remaining,X-Request-Id,Idempotency-Key",
"cache-control": "max-age=0, private, must-revalidate",
"content-security-policy": "upgrade-insecure-requests;script-src 'self';connect-src 'self' blob: https://pleroma.soykaf.com wss://pleroma.soykaf.com;media-src 'self';img-src 'self' data: blob:;default-src 'none';base-uri 'self';frame-ancestors 'none';style-src 'self' 'unsafe-inline';font-src 'self';manifest-src 'self';",
"referrer-policy": "same-origin",
"x-content-type-options": "nosniff",
"x-download-options": "noopen",
"x-frame-options": "DENY",
"x-permitted-cross-domain-policies": "none",
"x-request-id": "FnP3HZA8tRWC7E4EYzyS",
"x-xss-protection": "1; mode=block"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": {
"User-Agent": "localhost - Mobilizon 1.1.0-32-gbd53bfc4-dirty",
"Accept": "application/json, application/activity+json, application/jrd+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
"recv_timeout": 20000
},
"request_body": "",
"url": "http://pleroma.soykaf.com/.well-known/webfinger?resource=acct:lain@pleroma.soykaf.com"
"url": "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:lain@pleroma.soykaf.com"
},
"response": {
"binary": false,
"body": "{\"aliases\":[\"https://pleroma.soykaf.com/users/lain\"],\"links\":[{\"href\":\"https://pleroma.soykaf.com/users/lain/feed.atom\",\"rel\":\"http://schemas.google.com/g/2010#updates-from\",\"type\":\"application/atom+xml\"},{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"http://webfinger.net/rel/profile-page\",\"type\":\"text/html\"},{\"href\":\"https://pleroma.soykaf.com/users/lain/salmon\",\"rel\":\"salmon\"},{\"href\":\"data:application/magic-public-key,RSA.u39dKLin8N4PywPvasEGXstOMsgg9m1OEKnpfHnSHqc6UOtIPs5-aI_LcLbhIEH2EVl6jstvtqMIloPch1FizZ3OBiKz81dXTiEZ3NfKgj_GJfIlipChAadxrmUyWT_Pr0qPaF1vhPrkSTwR8iDNUiQ-OEggRPpJVkJ619MXNdsJE59yklZiD1WY0vC9aG9m-dh0BANKNwSjwfZ3uFjDh0UosMATKjPTSO_I59nK_lArex_jAwTnVm6Dryk2qR2XXZyzTzZAHuYqSM77RlsNTJUCOaSadl816eZAvU3TF-ibIou0D-0sN-M-QehRh93sVJ95U40GQz8jOGc_5wK8xw==.AQAB\",\"rel\":\"magic-public-key\"},{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"self\",\"type\":\"application/activity+json\"},{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"self\",\"type\":\"application/ld+json; profile=\\\"https://www.w3.org/ns/activitystreams\\\"\"},{\"rel\":\"http://ostatus.org/schema/1.0/subscribe\",\"template\":\"https://pleroma.soykaf.com/ostatus_subscribe?acct={uri}\"}],\"subject\":\"acct:lain@pleroma.soykaf.com\"}",
"body": "{\"aliases\":[\"https://pleroma.soykaf.com/users/lain\"],\"links\":[{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"http://webfinger.net/rel/profile-page\",\"type\":\"text/html\"},{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"self\",\"type\":\"application/activity+json\"},{\"href\":\"https://pleroma.soykaf.com/users/lain\",\"rel\":\"self\",\"type\":\"application/ld+json; profile=\\\"https://www.w3.org/ns/activitystreams\\\"\"},{\"rel\":\"http://ostatus.org/schema/1.0/subscribe\",\"template\":\"https://pleroma.soykaf.com/ostatus_subscribe?acct={uri}\"}],\"subject\":\"acct:lain@pleroma.soykaf.com\"}",
"headers": {
"Server": "nginx/1.10.3",
"Date": "Tue, 13 Nov 2018 11:11:11 GMT",
"Server": "nginx/1.18.0 (Ubuntu)",
"Date": "Thu, 08 Apr 2021 18:59:57 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1214",
"Content-Length": "576",
"Connection": "keep-alive",
"Vary": "Accept-Encoding",
"cache-control": "max-age=0, private, must-revalidate",
"x-request-id": "2ljal4oljell0gfni41am571",
"access-control-allow-origin": "*",
"access-control-expose-headers": "",
"access-control-allow-credentials": "true",
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
"Access-Control-Allow-Headers": "Authorization, Content-Type",
"X-XSS-Protection": "1; mode=block",
"X-Permitted-Cross-Domain-Policies": "none",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"Referrer-Policy": "same-origin",
"X-Download-Options": "noopen"
"access-control-allow-origin": "*",
"access-control-expose-headers": "Link,X-RateLimit-Reset,X-RateLimit-Limit,X-RateLimit-Remaining,X-Request-Id,Idempotency-Key",
"cache-control": "max-age=0, private, must-revalidate",
"content-security-policy": "upgrade-insecure-requests;script-src 'self';connect-src 'self' blob: https://pleroma.soykaf.com wss://pleroma.soykaf.com;media-src 'self';img-src 'self' data: blob:;default-src 'none';base-uri 'self';frame-ancestors 'none';style-src 'self' 'unsafe-inline';font-src 'self';manifest-src 'self';",
"referrer-policy": "same-origin",
"x-content-type-options": "nosniff",
"x-download-options": "noopen",
"x-frame-options": "DENY",
"x-permitted-cross-domain-policies": "none",
"x-request-id": "FnP3HZJ_kh8ymy8E1OCx",
"x-xss-protection": "1; mode=block"
},
"status_code": 200,
"type": "ok"

View file

@ -23,9 +23,9 @@ defmodule Mobilizon.Web.WebFingerControllerTest do
conn = get(conn, "/.well-known/host-meta")
assert response(conn, 200) ==
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\"><Link rel=\"lrdd\" template=\"#{
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/ns/1.0\"><hm:Host>mobilizon.test</hm:Host><Link rel=\"lrdd\" template=\"#{
Endpoint.url()
}/.well-known/webfinger?resource={uri}\" type=\"application/xrd+xml\" /></XRD>"
}/.well-known/webfinger?resource={uri}\" type=\"application/jrd+json\" /></XRD>"
assert {"content-type", "application/xrd+xml; charset=utf-8"} in conn.resp_headers
end