Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Added WebFinger support to my email address using one rewrite rule and one static file.

View gist:5846789
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
[aaron@parecki.com www]$ cat .htaccess
RewriteEngine on
RewriteCond %{QUERY_STRING} resource=acct:(.+)
RewriteRule ^\.well-known/webfinger /profile/%1? [L]
 
[aaron@parecki.com www]$ cat profile/aaron@parecki.com
{
"subject": "acct:aaron@parecki.com",
"links": [
{
"rel": "http://webfinger.net/rel/avatar",
"href": "http://aaronparecki.com/images/aaronpk.png"
},
{
"rel": "http://webfinger.net/rel/profile-page",
"href": "http://aaronparecki.com/"
},
{
"rel": "me",
"href": "http://aaronparecki.com/"
}
]
}

I had to change the rewrite rule to this to make it work:

RewriteRule ^/.well-known/webfinger /profile/%1? [L]

(forward slash instead of backslash)

Actually there are three problems with this:

  • URL-encoded query parameters are not unescaped prior to the mod_rewrite match
  • the content-type is not set
  • CORS headers are missing

Here's my version:

<Directory /var/www/profile>
    DefaultType application/json
    Header set Access-Control-Allow-Origin: "*"
</Directory>

RewriteEngine on
RewriteMap unescape int:unescape
RewriteCond ${unescape:%{QUERY_STRING}} resource=acct:(.+)
RewriteRule ^/.well-known/webfinger /profile/${unescape:%1}? [last]

This passes all of the checks on http://webfinger.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.