mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
authenticated fetch fixes
This commit is contained in:
parent
c64a973f6f
commit
30f40fd0d2
3 changed files with 58 additions and 1 deletions
|
@ -325,7 +325,10 @@ class ActivityStreams {
|
|||
function get_compound_property($property, $base = '', $namespace = '', $first = false) {
|
||||
$x = $this->get_property_obj($property, $base, $namespace);
|
||||
if($this->is_url($x)) {
|
||||
$x = $this->fetch_property($x);
|
||||
$y = $this->fetch_property($x);
|
||||
if (is_array($y)) {
|
||||
$x = $y;
|
||||
}
|
||||
}
|
||||
|
||||
// verify and unpack JSalmon signature if present
|
||||
|
|
|
@ -45,6 +45,12 @@ class Item extends Controller {
|
|||
if(! $item_id)
|
||||
http_status_exit(404, 'Not found');
|
||||
|
||||
$sigdata = HTTPSig::verify(EMPTY_STR);
|
||||
if($sigdata['portable_id'] && $sigdata['header_valid']) {
|
||||
$portable_id = $sigdata['portable_id'];
|
||||
observer_auth($portable_id);
|
||||
}
|
||||
|
||||
$item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
|
||||
|
||||
$sql_extra = item_permissions_sql(0);
|
||||
|
@ -116,6 +122,7 @@ class Item extends Controller {
|
|||
$sigdata = HTTPSig::verify(EMPTY_STR);
|
||||
if($sigdata['portable_id'] && $sigdata['header_valid']) {
|
||||
$portable_id = $sigdata['portable_id'];
|
||||
observer_auth($portable_id);
|
||||
}
|
||||
|
||||
$item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
|
||||
|
|
|
@ -354,3 +354,50 @@ function owt_init($token) {
|
|||
|
||||
logger('OpenWebAuth: auth success from ' . $hubloc['xchan_addr']);
|
||||
}
|
||||
|
||||
function observer_auth($ob_hash) {
|
||||
|
||||
if($ob_hash === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash
|
||||
where hubloc_addr = '%s' or hubloc_id_url = '%s' or hubloc_hash = '%s' order by hubloc_id desc",
|
||||
dbesc($ob_hash),
|
||||
dbesc($ob_hash),
|
||||
dbesc($ob_hash)
|
||||
);
|
||||
|
||||
if(! $r) {
|
||||
// finger them if they can't be found.
|
||||
$wf = discover_by_webbie($ob_hash);
|
||||
if($wf) {
|
||||
$r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash
|
||||
where hubloc_addr = '%s' or hubloc_id_url = '%s' or hubloc_hash = '%s' order by hubloc_id desc",
|
||||
dbesc($ob_hash),
|
||||
dbesc($ob_hash),
|
||||
dbesc($ob_hash)
|
||||
);
|
||||
}
|
||||
}
|
||||
if(! $r) {
|
||||
logger('unable to finger ' . $ob_hash);
|
||||
return;
|
||||
}
|
||||
|
||||
$hubloc = $r[0];
|
||||
|
||||
$_SESSION['authenticated'] = 1;
|
||||
|
||||
// normal visitor (remote_channel) login session credentials
|
||||
$_SESSION['visitor_id'] = $hubloc['xchan_hash'];
|
||||
$_SESSION['my_url'] = $hubloc['xchan_url'];
|
||||
$_SESSION['my_address'] = $hubloc['hubloc_addr'];
|
||||
$_SESSION['remote_hub'] = $hubloc['hubloc_url'];
|
||||
$_SESSION['DNT'] = 1;
|
||||
|
||||
\App::set_observer($hubloc);
|
||||
require_once('include/security.php');
|
||||
\App::set_groups(init_groups_visitor($_SESSION['visitor_id']));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue