aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-11-30 14:56:08 -0800
committerzotlabs <mike@macgirvin.com>2017-11-30 14:56:08 -0800
commitef4a0e5af5a249879e446636bd0ade54e2df0b9b (patch)
treede407ad63cb6275643e2bec8f4fdea0b26d9b51a /Zotlabs/Module
parent3acc5b05086548a3f1bc2beb744d3fb03703b6a5 (diff)
parentfc5b6887168a25992fb089ed7da7ac917e7aaf6b (diff)
downloadvolse-hubzilla-ef4a0e5af5a249879e446636bd0ade54e2df0b9b.tar.gz
volse-hubzilla-ef4a0e5af5a249879e446636bd0ade54e2df0b9b.tar.bz2
volse-hubzilla-ef4a0e5af5a249879e446636bd0ade54e2df0b9b.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Cdav.php2
-rw-r--r--Zotlabs/Module/Getfile.php57
2 files changed, 47 insertions, 12 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 77052f97c..91d279f7a 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -1250,7 +1250,7 @@ class Cdav extends \Zotlabs\Web\Controller {
//create default addressbook
$carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
$properties = ['{DAV:}displayname' => t('Default Addressbook')];
- $carddavBackend->createAddressBook($uri, $default, $properties);
+ $carddavBackend->createAddressBook($uri, 'default', $properties);
}
}
diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php
index 413a68e0c..abc9f50d9 100644
--- a/Zotlabs/Module/Getfile.php
+++ b/Zotlabs/Module/Getfile.php
@@ -28,17 +28,51 @@ class Getfile extends \Zotlabs\Web\Controller {
function post() {
- logger('post: ' . print_r($_POST,true),LOGGER_DEBUG,LOG_INFO);
-
+ $header_verified = false;
+
$hash = $_POST['hash'];
$time = $_POST['time'];
$sig = $_POST['signature'];
$resource = $_POST['resource'];
$revision = intval($_POST['revision']);
$resolution = (-1);
-
+
if(! $hash)
killme();
+
+ foreach([ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $head) {
+ if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') {
+ if($head !== 'HTTP_AUTHORIZATION') {
+ $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head];
+ continue;
+ }
+
+ $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
+ if($sigblock) {
+ $keyId = $sigblock['keyId'];
+
+ if($keyId) {
+ $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
+ where hubloc_addr = '%s' limit 1",
+ dbesc(str_replace('acct:','',$keyId))
+ );
+ if($r) {
+ $hubloc = $r[0];
+ $verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']);
+ if($verified && $verified['header_signed'] && $verified['header_valid'] && $hash == $hubloc['hubloc_hash']) {
+ $header_verified = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ logger('post: ' . print_r($_POST,true),LOGGER_DEBUG,LOG_INFO);
+ if($header_verified) {
+ logger('HTTPSig verified');
+ }
$channel = channelx_by_hash($hash);
@@ -59,16 +93,17 @@ class Getfile extends \Zotlabs\Web\Controller {
$d1 = datetime_convert('UTC','UTC',"now + $slop minutes");
$d2 = datetime_convert('UTC','UTC',"now - $slop minutes");
- if(($time > $d1) || ($time < $d2)) {
- logger('time outside allowable range');
- killme();
- }
+ if(! $header_verified) {
+ if(($time > $d1) || ($time < $d2)) {
+ logger('time outside allowable range');
+ killme();
+ }
- if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) {
- logger('verify failed.');
- killme();
+ if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) {
+ logger('verify failed.');
+ killme();
+ }
}
-
if($resolution > 0) {
$r = q("select * from photo where resource_id = '%s' and uid = %d limit 1",