mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-23 06:51:27 +00:00
commit
46da333fb1
4 changed files with 29 additions and 38 deletions
|
@ -118,20 +118,18 @@ class FederationController extends Controller
|
||||||
public function userOutbox(Request $request, $username)
|
public function userOutbox(Request $request, $username)
|
||||||
{
|
{
|
||||||
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
||||||
abort_if(!config('federation.activitypub.outbox'), 404);
|
|
||||||
|
|
||||||
// $profile = Profile::whereNull('domain')
|
if(!$request->wantsJson()) {
|
||||||
// ->whereNull('status')
|
return redirect('/' . $username);
|
||||||
// ->whereIsPrivate(false)
|
}
|
||||||
// ->whereUsername($username)
|
|
||||||
// ->firstOrFail();
|
|
||||||
|
|
||||||
// $key = 'ap:outbox:latest_10:pid:' . $profile->id;
|
$res = [
|
||||||
// $ttl = now()->addMinutes(15);
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
// $res = Cache::remember($key, $ttl, function() use($profile) {
|
'id' => 'https://' . config('pixelfed.domain.app') . '/users/' . $username . '/outbox',
|
||||||
// return Outbox::get($profile);
|
'type' => 'OrderedCollection',
|
||||||
// });
|
'totalItems' => 0,
|
||||||
$res = [];
|
'orderedItems' => []
|
||||||
|
];
|
||||||
|
|
||||||
return response(json_encode($res, JSON_UNESCAPED_SLASHES))->header('Content-Type', 'application/ld+json; profile="http://www.w3.org/ns/activitystreams"');
|
return response(json_encode($res, JSON_UNESCAPED_SLASHES))->header('Content-Type', 'application/ld+json; profile="http://www.w3.org/ns/activitystreams"');
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class InboxValidator implements ShouldQueue
|
||||||
protected $headers;
|
protected $headers;
|
||||||
protected $payload;
|
protected $payload;
|
||||||
|
|
||||||
public $timeout = 60;
|
public $timeout = 300;
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
public $maxExceptions = 1;
|
public $maxExceptions = 1;
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@ class InboxValidator implements ShouldQueue
|
||||||
if($this->verifySignature($headers, $profile, $payload) == true) {
|
if($this->verifySignature($headers, $profile, $payload) == true) {
|
||||||
(new Inbox($headers, $profile, $payload))->handle();
|
(new Inbox($headers, $profile, $payload))->handle();
|
||||||
return;
|
return;
|
||||||
} else if($this->blindKeyRotation($headers, $profile, $payload) == true) {
|
|
||||||
(new Inbox($headers, $profile, $payload))->handle();
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,18 +93,18 @@ class InboxValidator implements ShouldQueue
|
||||||
$signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
|
$signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
|
||||||
$date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
|
$date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
|
||||||
if(!$signature) {
|
if(!$signature) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$date) {
|
if(!$date) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!now()->parse($date)->gt(now()->subDays(1)) ||
|
if(!now()->parse($date)->gt(now()->subDays(1)) ||
|
||||||
!now()->parse($date)->lt(now()->addDays(1))
|
!now()->parse($date)->lt(now()->addDays(1))
|
||||||
) {
|
) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!isset($bodyDecoded['id'])) {
|
if(!isset($bodyDecoded['id'])) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
||||||
$keyId = Helpers::validateUrl($signatureData['keyId']);
|
$keyId = Helpers::validateUrl($signatureData['keyId']);
|
||||||
|
@ -127,12 +124,11 @@ class InboxValidator implements ShouldQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) {
|
if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) {
|
if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) {
|
||||||
return;
|
return false;
|
||||||
abort(400, 'Invalid request');
|
|
||||||
}
|
}
|
||||||
$actor = Profile::whereKeyId($keyId)->first();
|
$actor = Profile::whereKeyId($keyId)->first();
|
||||||
if(!$actor) {
|
if(!$actor) {
|
||||||
|
@ -140,11 +136,11 @@ class InboxValidator implements ShouldQueue
|
||||||
$actor = Helpers::profileFirstOrNew($actorUrl);
|
$actor = Helpers::profileFirstOrNew($actorUrl);
|
||||||
}
|
}
|
||||||
if(!$actor) {
|
if(!$actor) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$pkey = openssl_pkey_get_public($actor->public_key);
|
$pkey = openssl_pkey_get_public($actor->public_key);
|
||||||
if(!$pkey) {
|
if(!$pkey) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
$inboxPath = "/users/{$profile->username}/inbox";
|
$inboxPath = "/users/{$profile->username}/inbox";
|
||||||
list($verified, $headers) = HttpSignature::verify($pkey, $signatureData, $headers, $inboxPath, $body);
|
list($verified, $headers) = HttpSignature::verify($pkey, $signatureData, $headers, $inboxPath, $body);
|
||||||
|
|
|
@ -25,7 +25,7 @@ class InboxWorker implements ShouldQueue
|
||||||
protected $headers;
|
protected $headers;
|
||||||
protected $payload;
|
protected $payload;
|
||||||
|
|
||||||
public $timeout = 60;
|
public $timeout = 300;
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
public $maxExceptions = 1;
|
public $maxExceptions = 1;
|
||||||
|
|
||||||
|
@ -68,9 +68,6 @@ class InboxWorker implements ShouldQueue
|
||||||
if($this->verifySignature($headers, $payload) == true) {
|
if($this->verifySignature($headers, $payload) == true) {
|
||||||
(new Inbox($headers, $profile, $payload))->handle();
|
(new Inbox($headers, $profile, $payload))->handle();
|
||||||
return;
|
return;
|
||||||
} else if($this->blindKeyRotation($headers, $payload) == true) {
|
|
||||||
(new Inbox($headers, $profile, $payload))->handle();
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -83,18 +80,18 @@ class InboxWorker implements ShouldQueue
|
||||||
$signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
|
$signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
|
||||||
$date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
|
$date = is_array($headers['date']) ? $headers['date'][0] : $headers['date'];
|
||||||
if(!$signature) {
|
if(!$signature) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$date) {
|
if(!$date) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!now()->parse($date)->gt(now()->subDays(1)) ||
|
if(!now()->parse($date)->gt(now()->subDays(1)) ||
|
||||||
!now()->parse($date)->lt(now()->addDays(1))
|
!now()->parse($date)->lt(now()->addDays(1))
|
||||||
) {
|
) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if(!isset($bodyDecoded['id'])) {
|
if(!isset($bodyDecoded['id'])) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
$signatureData = HttpSignature::parseSignatureHeader($signature);
|
||||||
$keyId = Helpers::validateUrl($signatureData['keyId']);
|
$keyId = Helpers::validateUrl($signatureData['keyId']);
|
||||||
|
@ -114,11 +111,11 @@ class InboxWorker implements ShouldQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) {
|
if(parse_url($attr, PHP_URL_HOST) !== $keyDomain) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) {
|
if(!$keyDomain || !$idDomain || $keyDomain !== $idDomain) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$actor = Profile::whereKeyId($keyId)->first();
|
$actor = Profile::whereKeyId($keyId)->first();
|
||||||
if(!$actor) {
|
if(!$actor) {
|
||||||
|
@ -126,11 +123,11 @@ class InboxWorker implements ShouldQueue
|
||||||
$actor = Helpers::profileFirstOrNew($actorUrl);
|
$actor = Helpers::profileFirstOrNew($actorUrl);
|
||||||
}
|
}
|
||||||
if(!$actor) {
|
if(!$actor) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$pkey = openssl_pkey_get_public($actor->public_key);
|
$pkey = openssl_pkey_get_public($actor->public_key);
|
||||||
if(!$pkey) {
|
if(!$pkey) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
$inboxPath = "/f/inbox";
|
$inboxPath = "/f/inbox";
|
||||||
list($verified, $headers) = HttpSignature::verify($pkey, $signatureData, $headers, $inboxPath, $body);
|
list($verified, $headers) = HttpSignature::verify($pkey, $signatureData, $headers, $inboxPath, $body);
|
||||||
|
|
|
@ -17,7 +17,7 @@ class SharedInboxWorker implements ShouldQueue
|
||||||
protected $profile;
|
protected $profile;
|
||||||
protected $payload;
|
protected $payload;
|
||||||
|
|
||||||
public $timeout = 60;
|
public $timeout = 300;
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue