Mastodon and WebFinger

#ntsystems, #powershell edit this page

With the uncertainty surrounding Twitter I have decided to set up an account on Mastodon. If you haven’t heard about it Mastodon is an de-centralized, open-source alternative to centralized social media. It is powered by open protocols such as ActivityPub and WebFinger which allow federation of individual servers (called instances).

If a user on one server searches for a user on another server, they will enter the full name, i.e. @[email protected], into the search field. The server will then look for information about the user at the path If found, the reply contains information about where the profile of the user can be found.

We can use this protocol to be discoverable by servers on our own domain. We are using Bridgetown to build this site so placing a JSON file at this path src/.well-known/webfinger did the trick. So even though my profile is currently hosted at you can still find me with @[email protected]. And if you do find me, give me a follow :)

I used this PowerShell function to test the WebFinger endpoint on our and other sites.

function Invoke-WebFinger {
    process {
            $Username, $server = $uri -replace '^@' -split '@'
        $webFingerUri = "https://$server/.well-known/webfinger?resource=acct:$Username@$Server"
        Write-Verbose "GET $webFingerUri"
        $r = Invoke-RestMethod -Uri $webFingerUri
            Uri = $Username,$Server -join '@'
            Subject = $r.subject
            Aliases = $r.Aliases
            ProfilePage = $r.links.where{$_.rel -eq ''}.href

# Examples

'[email protected]','@[email protected]' | Invoke-WebFinger

Invoke-WebFinger -Uri

Invoke-WebFinger -Server -Username tom

Other people wrote about this: