mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-21 22:11:26 +00:00
Update HttpSignatures, update instance actor headers. Fixes #2935
This commit is contained in:
parent
213bed7cd1
commit
a900de2121
2 changed files with 7 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use Zttp\Zttp;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Util\ActivityPub\Helpers;
|
use App\Util\ActivityPub\Helpers;
|
||||||
use App\Util\ActivityPub\HttpSignature;
|
use App\Util\ActivityPub\HttpSignature;
|
||||||
|
@ -15,14 +15,13 @@ class ActivityPubFetchService
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = HttpSignature::instanceActorSign($url, false, [
|
$headers = HttpSignature::instanceActorSign($url, false);
|
||||||
'Accept' => 'application/activity+json, application/json',
|
$headers['Accept'] = 'application/activity+json, application/json';
|
||||||
'User-Agent' => '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')'
|
$headers['User-Agent'] = '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')';
|
||||||
]);
|
|
||||||
|
|
||||||
return Zttp::withHeaders($headers)
|
return Http::withHeaders($headers)
|
||||||
->timeout(30)
|
->timeout(30)
|
||||||
->get($url)
|
->get($url)
|
||||||
->body();
|
->body();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class HttpSignature {
|
||||||
$digest = self::_digest($body);
|
$digest = self::_digest($body);
|
||||||
}
|
}
|
||||||
$headers = self::_headersToSign($url, $body ? $digest : false);
|
$headers = self::_headersToSign($url, $body ? $digest : false);
|
||||||
$headers = array_unique(array_merge($headers, $addlHeaders));
|
$headers = array_merge($headers, $addlHeaders);
|
||||||
$stringToSign = self::_headersToSigningString($headers);
|
$stringToSign = self::_headersToSigningString($headers);
|
||||||
$signedHeaders = implode(' ', array_map('strtolower', array_keys($headers)));
|
$signedHeaders = implode(' ', array_map('strtolower', array_keys($headers)));
|
||||||
$key = openssl_pkey_get_private($privateKey);
|
$key = openssl_pkey_get_private($privateKey);
|
||||||
|
@ -133,7 +133,6 @@ class HttpSignature {
|
||||||
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
|
'Date' => $date->format('D, d M Y H:i:s \G\M\T'),
|
||||||
'Host' => parse_url($url, PHP_URL_HOST),
|
'Host' => parse_url($url, PHP_URL_HOST),
|
||||||
'Accept' => 'application/activity+json, application/json',
|
'Accept' => 'application/activity+json, application/json',
|
||||||
'Content-Type' => 'application/activity+json'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if($digest) {
|
if($digest) {
|
||||||
|
|
Loading…
Reference in a new issue