aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Magic.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-09-07 17:56:02 -0700
committerzotlabs <mike@macgirvin.com>2017-09-07 17:56:02 -0700
commit61f339a874784d3181f4c884bab9994ec9200f50 (patch)
treebd8236627c98408d3d0c898286e5adc0faf27336 /Zotlabs/Module/Magic.php
parent23e774db8ea25ba8eb8d8d5d6731622998534bbc (diff)
downloadvolse-hubzilla-61f339a874784d3181f4c884bab9994ec9200f50.tar.gz
volse-hubzilla-61f339a874784d3181f4c884bab9994ec9200f50.tar.bz2
volse-hubzilla-61f339a874784d3181f4c884bab9994ec9200f50.zip
owa - first commit
Diffstat (limited to 'Zotlabs/Module/Magic.php')
-rw-r--r--Zotlabs/Module/Magic.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php
index bf3198067..0eb2f27a1 100644
--- a/Zotlabs/Module/Magic.php
+++ b/Zotlabs/Module/Magic.php
@@ -17,6 +17,7 @@ class Magic extends \Zotlabs\Web\Controller {
$dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : '');
$test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0);
$rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0);
+ $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0);
$delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : '');
$parsed = parse_url($dest);
@@ -132,12 +133,41 @@ class Magic extends \Zotlabs\Web\Controller {
if(local_channel()) {
$channel = \App::get_channel();
+ // OpenWebAuth
+
+ if($owa) {
+
+ $headers = [];
+ $headers['Accept'] = 'application/x-zot+json' ;
+ $headers['X-Open-Web-Auth'] = random_string();
+ $headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],
+ 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
+
+ $x = z_fetch_url($basepath . '/owa',false,$redirects,[ 'headers' => $headers ]);
+ if($x['success']) {
+ $j = json_decode($x['body'],true);
+ if($j['success'] && $j['token']) {
+ $x = strpbrk($dest,'?&');
+ $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : '');
+ goaway($dest . $args);
+ }
+ }
+ goaway($dest);
+ }
+
+
$token = random_string();
+
// $token_sig = base64url_encode(rsa_sign($token,$channel['channel_prvkey']));
-
// $channel['token'] = $token;
// $channel['token_sig'] = $token_sig;
+
+
+
+
+
+
\Zotlabs\Zot\Verify::create('auth',$channel['channel_id'],$token,$x[0]['hubloc_url']);
$target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode(channel_reddress($channel))