From e1ad307b531c27ec6bfaf8b4d018991b0d4a78f3 Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 6 Dec 2024 20:43:26 +0000 Subject: initial commit hardcoded functionality mostly! --- routes/webfinger.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 routes/webfinger.php (limited to 'routes/webfinger.php') diff --git a/routes/webfinger.php b/routes/webfinger.php new file mode 100644 index 0000000..5994529 --- /dev/null +++ b/routes/webfinger.php @@ -0,0 +1,34 @@ +mount('/.well-known/webfinger', function (array $args) { + if (!isset($_GET['resource'])) { + throw new BadRequest('parameter `resource` is required'); + } + $resource = $_GET['resource']; + if (!str_starts_with($resource, 'acct:')) { + throw new BadRequest('only acct: URIs are supported'); + } + $handle = substr($resource, 5); + [$localPart, $remotePart] = explode('@', $handle, 2); + if ($remotePart != GlobalConfig::getInstance()->getCanonicalHost()) { + throw new NotFound('i only know about local accounts'); + } + if ($localPart != 'winter') { + throw new NotFound('i only know about winter!!!'); + } + json_response([ + 'subject' => "acct:$localPart@$remotePart", + 'links' => [ + [ + 'rel' => 'urn:example:wpf:actor', + 'href' => path_to_uri('/user/winter'), + 'type' => 'application/json' + ] + ] + ]); +}); \ No newline at end of file -- cgit v1.3