use Friendica\Core\System;
use Friendica\Model\Item;
use Friendica\Database\DBA;
+use Friendica\Util\HTTPSignature;
/**
* ActivityPub Objects
$a->internalRedirect(str_replace('objects/', 'display/', $a->query_string));
}
+ /// @todo Add Authentication to enable fetching of non public content
+ // $requester = HTTPSignature::getSigner('', $_SERVER);
+
$item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'origin' => true, 'private' => false]);
if (!DBA::isResult($item)) {
System::httpExit(404);
use Friendica\Protocol\ActivityPub;
use Friendica\Core\System;
use Friendica\Model\User;
+use Friendica\Util\HTTPSignature;
/**
* ActivityPub Outbox
$page = defaults($_REQUEST, 'page', null);
+ /// @todo Add Authentication to enable fetching of non public content
+ // $requester = HTTPSignature::getSigner('', $_SERVER);
+
$outbox = ActivityPub\Transmitter::getOutbox($owner, $page);
header('Content-Type: application/activity+json');
$ret['signature'] = base64_decode(preg_replace('/\s+/', '', $matches[1]));
}
- if (($ret['signature']) && ($ret['algorithm']) && (!$ret['headers'])) {
+ if (!empty($ret['signature']) && !empty($ret['algorithm']) && empty($ret['headers'])) {
$ret['headers'] = ['date'];
}
*/
public static function getSigner($content, $http_headers)
{
- $object = json_decode($content, true);
-
- if (empty($object)) {
+ if (empty($http_headers['HTTP_SIGNATURE'])) {
return false;
}
- $actor = JsonLD::fetchElement($object, 'actor', 'id');
+ if (!empty($content)) {
+ $object = json_decode($content, true);
+ if (empty($object)) {
+ return false;
+ }
+
+ $actor = JsonLD::fetchElement($object, 'actor', 'id');
+ } else {
+ $actor = '';
+ }
$headers = [];
$headers['(request-target)'] = strtolower($http_headers['REQUEST_METHOD']) . ' ' . $http_headers['REQUEST_URI'];