The fundamental part of ActivityPub federation is the "actor", or in Mastodon terms, the account. Accounts from other servers are queried and saved into the local database to allow sending and receiving interactions. The ResolveRemoteAccountService
class is responsible for this, working in two steps: Converting a human-readable handle like username@domain into URLs to the remote account's resources via Webfinger, and then using the linked remote account's JSON representation to create a local mirror.
Step 1: Webfinger
% curl -i "https://counter.social/.well-known/[email protected]"
HTTP/1.1 200 OK
Date: Thu, 04 Jan 2018 03:29:01 GMT
Content-Type: application/jrd+json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d92b6ebd83e928080fa0c0e02c239cd251515036540; expires=Fri, 04-Jan-19 03:29:00 GMT; path=/; domain=.counter.social; HttpOnly; Secure
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding
ETag: W/"48db3106c12dacbd51b5f62de6131219"
Cache-Control: max-age=0, private, must-revalidate
Set-Cookie: _mastodon_session=Qlo3U0xaaEZWcC9JWnJSWEtoYnFYZWRxdVJBQWpYSzVUVkJXeDJlQnpYdDZlL2hYRjJ2eU55WHVPekhGOGNvQXU0dFRYaVlzNmVoZnlWaWhET1RhcjJlZEJISkx2REVPY0drUk5Uck0zRE56U0MzMDlkMHZFZnI5N29uaGcxeVBoRjNKWldrTU5NaSszQnF5NFpDY0xNNElyeFdadnBlZGE0M1VzNzliaWVZPS0taHUvQVRnWGhWVkU3aW43ZHlyN3hPQT09--a6c348dcb942e661bdb525072a27b7ea3f0c7525; path=/; secure; HttpOnly
X-Request-Id: c4916bd6-4272-4460-89e4-d1961c3eef9f
X-Runtime: 0.016967
Strict-Transport-Security: max-age=0; preload
Server: cloudflare-nginx
CF-RAY: 3d7b1c6afab62d59-TXL
{"subject":"acct:[email protected]","aliases":["https://counter.social/@th3j35t3r","https://counter.social/users/th3j35t3r"],"links":[{"rel":"http://webfinger.net/rel/profile-page","type":"text/html","href":"https://counter.social/@th3j35t3r"},{"rel":"http://schemas.google.com/g/2010#updates-from","type":"application/atom+xml","href":"https://counter.social/users/th3j35t3r.atom"},{"rel":"self","type":"application/activity+json","href":"https://counter.social/users/th3j35t3r"},{"rel":"salmon","href":"https://counter.social/api/salmon/1"},{"rel":"magic-public-key","href":"data:application/magic-public-key,RSA.tVWgD3zo6Q7TkLdg_y0QCM94Z-U_0d1bYj_4wtvk0D-xWEQuhHAqWixiCJ_EL783dwtU6CzZxIaKX7wLw2TNyv06KZjpQe7hmph4SAt8BDxuVIbjlfRt0YjHej_RcfmdkbdCHeJV22UNZt1WKotFM-4j9wHJ58onNKQvISQojA413x9_uv-5gkDvvE87ZC0hivP9Z8YjUpxcz9uYNewJjUjKSYbas6HdtlmfydhdMT1zy98CVIN2qxeXkpbVVJp3BmSiib2xbac8DUoZkKnm5oiU2uZLGIzvfGUouUfk1d6y61f-qQtRNsY2slA1zcymDlq22qOC26ZQ1GTShT5Taw==.AQAB"},{"rel":"http://ostatus.org/schema/1.0/subscribe","template":"https://counter.social/authorize_follow?acct={uri}"}]}
Status: Still works
Step 2: ActivityPub actor
% curl -i -H "Accept: application/activity+json" "https://counter.social/users/th3j35t3r"
HTTP/1.1 302 Moved Temporarily
Date: Thu, 04 Jan 2018 03:29:51 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Location: https://counter.social/auth/sign_in
Strict-Transport-Security: max-age=0; preload
X-Content-Type-Options: nosniff
Server: cloudflare-nginx
CF-RAY: 3d7b1daac9a42d89-TXL
Status: Redirects to login page instead of returning JSON