initial testing success with owa

This commit is contained in:
zotlabs 2017-09-07 18:52:18 -07:00
parent 7e9162ef06
commit 1fbb1e6c2a
4 changed files with 7 additions and 4 deletions

View File

@ -33,7 +33,7 @@ logger('verified: ' . print_r($verified,true));
if($verified && $verified['header_signed'] && $verified['header_valid']) { if($verified && $verified['header_signed'] && $verified['header_valid']) {
$token = random_string(32); $token = random_string(32);
\Zotlabs\Zot\Verify::create('owt',0,token,$r[0]['hubloc_hash']); \Zotlabs\Zot\Verify::create('owt',0,$token,$r[0]['hubloc_addr']);
$x = json_encode([ 'success' => true, 'token' => $token ]); $x = json_encode([ 'success' => true, 'token' => $token ]);
header('Content-Type: application/x-zot+json'); header('Content-Type: application/x-zot+json');
echo $x; echo $x;

View File

@ -123,7 +123,7 @@ class Finger {
$x = json_decode($result['body'], true); $x = json_decode($result['body'], true);
$verify = \Zotlabs\Web\HTTPSig::verify($result,(($x) ? $x['key'] : '')); $verify = \Zotlabs\Web\HTTPSig::verify($result,(($x) ? $x['key'] : ''));
if($x && (! $verify['header_valid'])) { if($x && (! $verify['header_valid'])) {
$signed_token = ((is_array($x) && array_key_exists('signed_token', $x)) ? $x['signed_token'] : null); $signed_token = ((is_array($x) && array_key_exists('signed_token', $x)) ? $x['signed_token'] : null);
if($signed_token) { if($signed_token) {

View File

@ -33,7 +33,7 @@ class Verify {
function get_meta($type,$channel_id,$token) { function get_meta($type,$channel_id,$token) {
$r = q("select id from verify where vtype = '%s' and channel = %d and token = '%s' limit 1", $r = q("select id, meta from verify where vtype = '%s' and channel = %d and token = '%s' limit 1",
dbesc($type), dbesc($type),
intval($channel_id), intval($channel_id),
dbesc($token) dbesc($token)

View File

@ -239,6 +239,7 @@ function owt_init($token) {
\Zotlabs\Zot\Verify::purge('owt','3 MINUTE'); \Zotlabs\Zot\Verify::purge('owt','3 MINUTE');
$ob_hash = \Zotlabs\Zot\Verify::get_meta('owt',0,$token); $ob_hash = \Zotlabs\Zot\Verify::get_meta('owt',0,$token);
if($ob_hash === false) { if($ob_hash === false) {
return; return;
} }
@ -250,7 +251,7 @@ function owt_init($token) {
if(! $r) { if(! $r) {
// finger them if they can't be found. // finger them if they can't be found.
$j = Finger::run($ob_hash, null); $j = \Zotlabs\Zot\Finger::run($ob_hash, null);
if ($j['success']) { if ($j['success']) {
import_xchan($j); import_xchan($j);
$r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash
@ -265,6 +266,8 @@ function owt_init($token) {
} }
$hubloc = $r[0]; $hubloc = $r[0];
$_SESSION['authenticated'] = 1;
$delegate_success = false; $delegate_success = false;
if($_REQUEST['delegate']) { if($_REQUEST['delegate']) {
$r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1", $r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1",