Merge branch 'dev' of ../rebble.net into dev

This commit is contained in:
Mike Macgirvin 2022-06-21 16:49:30 -07:00
commit 0de1f9b590
2 changed files with 25 additions and 20 deletions

View file

@ -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;

View file

@ -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.