From af263031e86697b6136cadb61d3b23fa3a2cfd28 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 10 Aug 2018 15:15:02 -0500 Subject: [PATCH] add basic webfinger support, good enough for now --- viera/__init__.py | 2 ++ viera/webfinger.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 viera/webfinger.py diff --git a/viera/__init__.py b/viera/__init__.py index c32462d..71b7c2a 100644 --- a/viera/__init__.py +++ b/viera/__init__.py @@ -20,3 +20,5 @@ app = aiohttp.web.Application() from . import database from . import actor +from . import webfinger + diff --git a/viera/webfinger.py b/viera/webfinger.py new file mode 100644 index 0000000..71e172a --- /dev/null +++ b/viera/webfinger.py @@ -0,0 +1,24 @@ +import aiohttp.web +from . import app + + +async def webfinger(request): + subject = request.query['resource'] + + if subject != 'acct:viera@{}'.format(request.host): + return aiohttp.web.json_response({'error': 'user not found'}, status=404) + + actor_uri = "https://{}/actor".format(request.host) + data = { + "aliases": [actor_uri], + "links": [ + {"href": actor_uri, "rel": "self", "type": "application/activity+json"}, + {"href": actor_uri, "rel": "self", "type": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""} + ], + "subject": subject + } + + return aiohttp.web.json_response(data) + + +app.router.add_get('/.well-known/webfinger', webfinger)