Fix headers (string to array) and make sure the signature doesn't change
This commit is contained in:
parent
f2dcc2788d
commit
befd5c860d
3 changed files with 14 additions and 16 deletions
|
|
@ -88,9 +88,10 @@ class Magic extends BaseModule
|
|||
$exp = explode('/profile/', $contact['url']);
|
||||
$basepath = $exp[0];
|
||||
|
||||
$header = [];
|
||||
$header['Accept'] = 'application/x-dfrn+json, application/x-zot+json';
|
||||
$header['X-Open-Web-Auth'] = Strings::getRandomHex();
|
||||
$header = [
|
||||
'Accept' => ['application/x-dfrn+json', 'application/x-zot+json'],
|
||||
'X-Open-Web-Auth' => [Strings::getRandomHex()],
|
||||
];
|
||||
|
||||
// Create a header that is signed with the local users private key.
|
||||
$header = HTTPSignature::createSig(
|
||||
|
|
|
|||
|
|
@ -140,6 +140,9 @@ class HTTPSignature
|
|||
public static function createSig($head, $prvkey, $keyid = 'Key')
|
||||
{
|
||||
$return_headers = [];
|
||||
if (!empty($head)) {
|
||||
$return_headers = $head;
|
||||
}
|
||||
|
||||
$alg = 'sha512';
|
||||
$algorithm = 'rsa-sha512';
|
||||
|
|
@ -149,15 +152,7 @@ class HTTPSignature
|
|||
$headerval = 'keyId="' . $keyid . '",algorithm="' . $algorithm
|
||||
. '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"';
|
||||
|
||||
$sighead = 'Authorization: Signature ' . $headerval;
|
||||
|
||||
if ($head) {
|
||||
foreach ($head as $k => $v) {
|
||||
$return_headers[] = $k . ': ' . $v;
|
||||
}
|
||||
}
|
||||
|
||||
$return_headers[] = $sighead;
|
||||
$return_headers['Authorization'] = ['Signature ' . $headerval];
|
||||
|
||||
return $return_headers;
|
||||
}
|
||||
|
|
@ -176,6 +171,9 @@ class HTTPSignature
|
|||
$fields = '';
|
||||
|
||||
foreach ($head as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$v = implode(', ', $v);
|
||||
}
|
||||
$headers .= strtolower($k) . ': ' . trim($v) . "\n";
|
||||
if ($fields) {
|
||||
$fields .= ' ';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue