Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-09-21 17:44:59 -07:00
commit b772a5f564
8 changed files with 76 additions and 11 deletions

View File

@ -58,7 +58,7 @@ class ActivityStreams {
$this->saved_recips = $arr; $this->saved_recips = $arr;
} }
function collect_recips($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { function collect_recips($base = '',$namespace = '') {
$x = []; $x = [];
$fields = [ 'to','cc','bto','bcc','audience']; $fields = [ 'to','cc','bto','bcc','audience'];
foreach($fields as $f) { foreach($fields as $f) {
@ -75,7 +75,7 @@ class ActivityStreams {
return $x; return $x;
} }
function expand($arr,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { function expand($arr,$base = '',$namespace = '') {
$ret = []; $ret = [];
// right now use a hardwired recursion depth of 5 // right now use a hardwired recursion depth of 5
@ -103,8 +103,12 @@ class ActivityStreams {
function get_namespace($base,$namespace) { function get_namespace($base,$namespace) {
if(! $namespace)
return '';
$key = null; $key = null;
foreach( [ $this->data, $base ] as $b ) { foreach( [ $this->data, $base ] as $b ) {
if(! $b) if(! $b)
continue; continue;
@ -135,7 +139,7 @@ class ActivityStreams {
} }
function get_property_obj($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV ) { function get_property_obj($property,$base = '',$namespace = '' ) {
$prefix = $this->get_namespace($base,$namespace); $prefix = $this->get_namespace($base,$namespace);
if($prefix === null) if($prefix === null)
return null; return null;
@ -152,13 +156,13 @@ class ActivityStreams {
} }
$x = z_fetch_url($url,true,$redirects, $x = z_fetch_url($url,true,$redirects,
['headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json' ]]);
if($x['success']) if($x['success'])
return json_decode($x['body'],true); return json_decode($x['body'],true);
return null; return null;
} }
function get_compound_property($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { function get_compound_property($property,$base = '',$namespace = '') {
$x = $this->get_property_obj($property,$base,$namespace); $x = $this->get_property_obj($property,$base,$namespace);
if($this->is_url($x)) { if($this->is_url($x)) {
$x = $this->fetch_property($x); $x = $this->fetch_property($x);
@ -173,7 +177,7 @@ class ActivityStreams {
return false; return false;
} }
function get_primary_type($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { function get_primary_type($base = '',$namespace = '') {
if(! $base) if(! $base)
$base = $this->data; $base = $this->data;
$x = $this->get_property_obj('type',$base,$namespace); $x = $this->get_property_obj('type',$base,$namespace);

View File

@ -12,7 +12,10 @@ class LDSignatures {
$ohash = self::hash(self::signable_options($data['signature'])); $ohash = self::hash(self::signable_options($data['signature']));
$dhash = self::hash(self::signable_data($data)); $dhash = self::hash(self::signable_data($data));
return rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey); $x = rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey);
logger('LD-verify: ' . intval($x));
return $x;
} }
static function dopplesign(&$data,$channel) { static function dopplesign(&$data,$channel) {

View File

@ -28,6 +28,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
if(! $update) { if(! $update) {
nav_set_selected(t('Public Stream'));
$_SESSION['static_loadtime'] = datetime_convert(); $_SESSION['static_loadtime'] = datetime_convert();
$static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1);
@ -108,7 +110,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
$simple_update = ''; $simple_update = '';
if($static && $simple_update) if($static && $simple_update)
$simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
//logger('update: ' . $update . ' load: ' . $load); //logger('update: ' . $update . ' load: ' . $load);

View File

@ -50,6 +50,7 @@ class Xrd extends \Zotlabs\Web\Controller {
'$accturi' => $resource, '$accturi' => $resource,
'$subject' => $subject, '$subject' => $subject,
'$aliases' => $aliases, '$aliases' => $aliases,
'$channel_url' => z_root() . '/channel/' . $r[0]['channel_address'],
'$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'],
'$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'],
'$atom' => z_root() . '/ofeed/' . $r[0]['channel_address'], '$atom' => z_root() . '/ofeed/' . $r[0]['channel_address'],

View File

@ -20,7 +20,7 @@ class HTTPSig {
return $digest; return $digest;
} }
// See draft-cavage-http-signatures-07 // See draft-cavage-http-signatures-08
static function verify($data,$key = '') { static function verify($data,$key = '') {
@ -48,7 +48,7 @@ class HTTPSig {
else { else {
$headers = []; $headers = [];
$headers['(request-target)'] = $headers['(request-target)'] =
$_SERVER['REQUEST_METHOD'] . ' ' . strtolower($_SERVER['REQUEST_METHOD']) . ' ' .
$_SERVER['REQUEST_URI']; $_SERVER['REQUEST_URI'];
foreach($_SERVER as $k => $v) { foreach($_SERVER as $k => $v) {
if(strpos($k,'HTTP_') === 0) { if(strpos($k,'HTTP_') === 0) {
@ -70,6 +70,8 @@ class HTTPSig {
if(! $sig_block) if(! $sig_block)
return $result; return $result;
logger('sig_block: ' . print_r($sig_block,true), LOGGER_DATA);
$result['header_signed'] = true; $result['header_signed'] = true;
$signed_headers = $sig_block['headers']; $signed_headers = $sig_block['headers'];
@ -110,6 +112,8 @@ class HTTPSig {
$x = rsa_verify($signed_data,$sig_block['signature'],$key,$algorithm); $x = rsa_verify($signed_data,$sig_block['signature'],$key,$algorithm);
logger('verified: ' . $x, LOGGER_DEBUG);
if($x === false) if($x === false)
return $result; return $result;
@ -130,6 +134,8 @@ class HTTPSig {
} }
} }
logger('Content_Valid: ' . $result['content_valid']);
return $result; return $result;
} }

View File

@ -178,6 +178,25 @@ class Router {
*/ */
if(\App::$module_loaded) { if(\App::$module_loaded) {
if (( \App::$module === 'channel' ) && argc() > 1) {
\App::$channel_links = [
[
'rel' => 'lrdd',
'type' => 'application/xrd+xml',
'url' => z_root() . '/xrd?f=&uri=acct%3A' . argv(1) . '%40' . \App::get_hostname()
],
[
'rel' => 'jrd',
'type' => 'application/jrd+json',
'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . \App::get_hostname()
],
];
$x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ];
call_hooks('channel_links', $x );
\App::$channel_links = $x['channel_links'];
header('Link: ' . \App::get_channel_links());
}
\App::$page['page_title'] = \App::$module; \App::$page['page_title'] = \App::$module;
$placeholder = ''; $placeholder = '';

View File

@ -456,7 +456,16 @@ define ( 'NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/' );
define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' ); define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' );
define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' ); define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' );
define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams-history/v1.8.jsonld' ); // We should be using versioned jsonld contexts so that signatures will be slightly more reliable.
// Why signatures are unreliable by design is a problem nobody seems to care about
// "because it's a proposed W3C standard". .
// Anyway, if you use versioned contexts, communication with Mastodon fails. Have not yet investigated
// the reason for the dependency but for the current time, use the standard non-versioned context.
//define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams-history/v1.8.jsonld' );
define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' );
define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.2' ); define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.2' );
/** /**
* activity stream defines * activity stream defines
@ -782,6 +791,10 @@ class App {
public static $is_tablet = false; public static $is_tablet = false;
public static $comanche; public static $comanche;
public static $channel_links;
public static $category; public static $category;
// Allow themes to control internal parameters // Allow themes to control internal parameters
@ -929,6 +942,7 @@ class App {
self::$module = 'home'; self::$module = 'home';
} }
/* /*
* See if there is any page number information, and initialise * See if there is any page number information, and initialise
* pagination * pagination
@ -1026,6 +1040,19 @@ class App {
return self::$path; return self::$path;
} }
public static function get_channel_links() {
$s = '';
$x = self::$channel_links;
if($x && is_array($x) && count($x)) {
foreach($x as $y) {
if($s) {
$s .= ',';
}
$s .= '<' . $y['url'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"';
}
}
return $s;
}
public static function set_account($acct) { public static function set_account($acct) {
self::$account = $acct; self::$account = $acct;
} }

View File

@ -91,6 +91,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl] [zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl]
Called when removing a channel Called when removing a channel
[zrl=[baseurl]/help/hook/channel_links]channel_links[/zrl]
Called when generating the Link: HTTP header for a channel
[zrl=[baseurl]/help/hook/channel_settings]channel_settings[/zrl] [zrl=[baseurl]/help/hook/channel_settings]channel_settings[/zrl]
Called when displaying the channel settings page Called when displaying the channel settings page