webfinger: handle Bridgy Fed actor URLs

hoping to fix errors like this on Mastodon AP delivery:
`Received 401: Public key not found for key https://fed.brid.gy/snarfed.org`
pull/292/head
Ryan Barrett 2022-11-17 07:56:00 -08:00
rodzic dde86008e2
commit f127a17fe5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -185,7 +185,8 @@ class WebfingerTest(testutil.TestCase):
mock_get.return_value = requests_response(self.html, url='https://foo.com/')
for resource in ('foo.com@foo.com', 'acct:foo.com@foo.com', 'xyz@foo.com',
'foo.com', 'http://foo.com/', 'https://foo.com/'):
'foo.com', 'http://foo.com/', 'https://foo.com/',
'http://localhost/foo.com'):
url = '/.well-known/webfinger?%s' % urllib.parse.urlencode(
{'resource': resource})
got = self.client.get(url, headers={'Accept': 'application/json'})

Wyświetl plik

@ -162,6 +162,10 @@ class Webfinger(Actor):
"""
def template_vars(self):
resource = flask_util.get_required_param('resource')
# handle Bridgy Fed actor URLs, eg https://fed.brid.gy/snarfed.org
resource = resource.removeprefix(request.host_url)
try:
user, domain = util.parse_acct_uri(resource)
if domain in common.DOMAINS: