This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(Tinebase Webfinger) add /.well-known/webfinger partial suppor…
…t (rfc 7033)
- Loading branch information
Showing
4 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
|
||
class Tinebase_Webfinger | ||
{ | ||
/** | ||
* Tinebase_Expressive_RoutHandler function | ||
* | ||
* @return \Zend\Diactoros\Response | ||
*/ | ||
public static function handlePublicGet(): \Zend\Diactoros\Response | ||
{ | ||
/** @var \Zend\Diactoros\ServerRequest $request */ | ||
$request = Tinebase_Core::getContainer()->get(\Psr\Http\Message\RequestInterface::class); | ||
$params = $request->getQueryParams(); | ||
if (!isset($params['resource']) || !isset($params['rel'])) { | ||
return static::badRequest(); | ||
} | ||
$resource = $params['resource']; | ||
$rel = $params['rel']; | ||
|
||
$response = new \Zend\Diactoros\Response('php://memory', 200, [ | ||
'Access-Control-Allow-Origin' => '*', | ||
'Content-Type' => 'application/jrd+json' | ||
]); | ||
|
||
$result = [ | ||
'subject' => $resource, | ||
'aliases' => [], | ||
'properties' => [], | ||
'links' => [] | ||
]; | ||
|
||
$relHandler = Tinebase_Config::getInstance()->{Tinebase_Config::WEBFINGER_REL_HANDLER}; | ||
if (isset($relHandler[$rel])) { | ||
call_user_func_array($relHandler[$rel], [&$result]); | ||
} | ||
|
||
$response->getBody()->write(json_encode($result)); | ||
|
||
return $response; | ||
} | ||
|
||
protected static function badRequest(): \Zend\Diactoros\Response | ||
{ | ||
return new \Zend\Diactoros\Response('php://memory', 400); | ||
} | ||
} |