mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 05:35:12 +00:00
Merge branch 'dev' of ../rebble.net into dev
This commit is contained in:
commit
0de1f9b590
2 changed files with 25 additions and 20 deletions
|
@ -8,6 +8,7 @@ use Code\Access\Permissions;
|
|||
use Code\Access\PermissionRoles;
|
||||
use Code\Access\PermissionLimits;
|
||||
use Code\Daemon\Run;
|
||||
use Code\Lib as Zlib;
|
||||
use Code\Lib\PConfig;
|
||||
use Code\Lib\XConfig;
|
||||
use Code\Lib\Config;
|
||||
|
|
|
@ -59,26 +59,6 @@ class ActivityStreams
|
|||
}
|
||||
|
||||
if ($this->data) {
|
||||
// verify and unpack JSalmon signature if present
|
||||
// This will only be the case for Zot6 packets
|
||||
|
||||
if (is_array($this->data) && array_key_exists('signed', $this->data)) {
|
||||
$ret = JSalmon::verify($this->data);
|
||||
$tmp = JSalmon::unpack($this->data['data']);
|
||||
if ($ret && $ret['success']) {
|
||||
if ($ret['signer']) {
|
||||
logger('Unpacked: ' . json_encode($tmp, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOGGER_DATA, LOG_DEBUG);
|
||||
$saved = json_encode($this->data, JSON_UNESCAPED_SLASHES);
|
||||
$this->data = $tmp;
|
||||
$this->meta['signer'] = $ret['signer'];
|
||||
$this->meta['signed_data'] = $saved;
|
||||
if ($ret['hubloc']) {
|
||||
$this->meta['hubloc'] = $ret['hubloc'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This indicates only that we have sucessfully decoded JSON.
|
||||
$this->valid = true;
|
||||
|
||||
|
@ -91,6 +71,30 @@ class ActivityStreams
|
|||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// verify and unpack JSalmon signature if present
|
||||
// This will only be the case for Zot6 packets
|
||||
|
||||
if ($this->valid && is_array($this->data) && array_key_exists('signed', $this->data)) {
|
||||
$ret = JSalmon::verify($this->data);
|
||||
$tmp = JSalmon::unpack($this->data['data']);
|
||||
if ($ret && $ret['success'] && $tmp) {
|
||||
if ($ret['signer']) {
|
||||
logger('Unpacked: ' . json_encode($tmp, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOGGER_DATA, LOG_DEBUG);
|
||||
$saved = json_encode($this->data, JSON_UNESCAPED_SLASHES);
|
||||
$this->data = $tmp;
|
||||
$this->meta['signer'] = $ret['signer'];
|
||||
$this->meta['signed_data'] = $saved;
|
||||
if ($ret['hubloc']) {
|
||||
$this->meta['hubloc'] = $ret['hubloc'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger('JSalmon verification failure.');
|
||||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to assemble an Activity from what we were given.
|
||||
|
|
Loading…
Reference in a new issue