From d523cc085ac9fad29ea0a450a411c5f6aa2244ba Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 25 Jan 2023 20:59:40 -0800 Subject: [PATCH] remove OStatus parts of Webfinger background on Mastodon interop: * https://docs.joinmastodon.org/spec/webfinger/ * https://github.com/mastodon/mastodon/pull/11280 * https://docs.joinmastodon.org/spec/activitypub/#publicKey --- tests/test_webfinger.py | 68 +---------------------------------------- webfinger.py | 41 ------------------------- 2 files changed, 1 insertion(+), 108 deletions(-) diff --git a/tests/test_webfinger.py b/tests/test_webfinger.py index 8309f434..744eaade 100644 --- a/tests/test_webfinger.py +++ b/tests/test_webfinger.py @@ -39,7 +39,6 @@ class WebfingerTest(testutil.TestCase): 'https://foo.com/about-me', 'https://foo.com/', ], - 'magic_keys': [{'value': self.key.href()}], 'links': [{ 'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', @@ -67,20 +66,10 @@ class WebfingerTest(testutil.TestCase): 'rel': 'sharedInbox', 'type': 'application/activity+json', 'href': 'http://localhost/inbox' - }, { - 'rel': 'magic-public-key', - 'href': self.key.href(), }, { 'rel': 'http://ostatus.org/schema/1.0/subscribe', 'template': 'http://localhost/user/foo.com?url={uri}', - }, { - 'rel': 'http://schemas.google.com/g/2010#updates-from', - 'type': 'application/atom+xml', - 'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F', - }, { - 'rel': 'hub', - 'href': 'https://bridgy-fed.superfeedr.com/' - }] + }], } def test_host_meta_xrd(self): @@ -116,50 +105,6 @@ class WebfingerTest(testutil.TestCase): self.assertEqual(self.expected_webfinger, got.json) - # check that magic key is persistent - again = self.client.get('/acct:foo.com', - headers={'Accept': 'application/json'}).json - self.assertEqual(self.key.href(), again['magic_keys'][0]['value']) - - links = {l['rel']: l.get('href') for l in again['links']} - self.assertEqual(self.key.href(), links['magic-public-key']) - - @mock.patch('requests.get') - def test_user_with_atom_feed(self, mock_get): - html = """\ - - - - - - -""" + self.html - mock_get.return_value = requests_response(html, url = 'https://foo.com/') - - got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'}) - self.assertEqual(200, got.status_code) - self.assertIn({ - 'rel': 'http://schemas.google.com/g/2010#updates-from', - 'type': 'application/atom+xml', - 'href': 'https://foo.com/use-this', - }, got.json['links']) - - @mock.patch('requests.get') - def test_user_with_push_header(self, mock_get): - mock_get.return_value = requests_response( - self.html, url = 'https://foo.com/', headers={ - 'Link': 'badly formatted, ' - "; rel='foo'," - '; rel="hub"', - }) - - got = self.client.get('/acct:foo.com', headers={'Accept': 'application/json'}) - self.assertEqual(200, got.status_code) - self.assertIn({ - 'rel': 'hub', - 'href': 'http://a.custom.hub/', - }, got.json['links']) - @mock.patch('requests.get') def test_user_no_hcard(self, mock_get): mock_get.return_value = requests_response(""" @@ -175,7 +120,6 @@ class WebfingerTest(testutil.TestCase): self.assert_equals({ 'subject': 'acct:foo.com@foo.com', 'aliases': ['https://foo.com/'], - 'magic_keys': [{'value': self.key.href()}], 'links': [{ 'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', @@ -196,16 +140,6 @@ class WebfingerTest(testutil.TestCase): 'rel': 'sharedInbox', 'type': 'application/activity+json', 'href': 'http://localhost/inbox' - }, { - 'rel': 'http://schemas.google.com/g/2010#updates-from', - 'type': 'application/atom+xml', - 'href': 'https://granary.io/url?input=html&output=atom&url=https%3A%2F%2Ffoo.com%2F&hub=https%3A%2F%2Ffoo.com%2F', - }, { - 'rel': 'hub', - 'href': 'https://bridgy-fed.superfeedr.com/' - }, { - 'rel': 'magic-public-key', - 'href': self.key.href(), }, { 'rel': 'http://ostatus.org/schema/1.0/subscribe', 'template': 'http://localhost/user/foo.com?url={uri}', diff --git a/webfinger.py b/webfinger.py index b22d8dbd..e7140103 100644 --- a/webfinger.py +++ b/webfinger.py @@ -84,7 +84,6 @@ class Actor(flask_util.XrdOrJrd): data = util.trim_nulls({ 'subject': 'acct:' + user.address().lstrip('@'), 'aliases': urls, - 'magic_keys': [{'value': user.href()}], 'links': sum(([{ 'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', @@ -119,13 +118,6 @@ class Actor(flask_util.XrdOrJrd): 'href': common.host_url('inbox'), }, - # OStatus - # TODO: remove? - { - 'rel': 'magic-public-key', - 'href': user.href(), - }, - # remote follow # https://socialhub.activitypub.rocks/t/what-is-the-current-spec-for-remote-follow/2020/11?u=snarfed # https://github.com/snarfed/bridgy-fed/issues/60#issuecomment-1325589750 @@ -135,39 +127,6 @@ class Actor(flask_util.XrdOrJrd): }] }) - # OStatus: discover atom feed, if any - # TODO: remove? - if resp: - feed = parsed.find('link', rel='alternate', type=atom.CONTENT_TYPE) - if feed and feed['href']: - feed = urllib.parse.urljoin(resp.url, feed['href']) - else: - feed = 'https://granary.io/url?' + urllib.parse.urlencode({ - 'input': 'html', - 'output': 'atom', - 'url': resp.url, - 'hub': resp.url, - }) - data['links'].append({ - 'rel': 'http://schemas.google.com/g/2010#updates-from', - 'type': atom.CONTENT_TYPE, - 'href': feed, - }) - - # OStatus: discover PuSH, if any - # TODO: remove? - if resp: - for link in resp.headers.get('Link', '').split(','): - match = common.LINK_HEADER_RE.match(link) - if match and match.group(2) == 'hub': - hub = match.group(1) - else: - hub = 'https://bridgy-fed.superfeedr.com/' - data['links'].append({ - 'rel': 'hub', - 'href': hub, - }) - logger.info(f'Returning WebFinger data: {json_dumps(data, indent=2)}') return data