mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 06:23:18 +00:00
Update InboxPipeline
This commit is contained in:
parent
d1b888b5a6
commit
3cfa8b69fb
2 changed files with 16 additions and 23 deletions
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue