From f0235c4a98e3f75afe6f4eb23b12d3b9a1c150ae Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Wed, 20 Jun 2018 18:38:23 +0200 Subject: [PATCH] port hubzillas OpenWebAuth - rename some methods and classes --- doc/Addons.md | 1 - index.php | 2 +- src/Model/Profile.php | 8 +++----- src/Module/Magic.php | 4 ++-- src/Module/Owa.php | 4 ++-- src/Util/{HTTPSig.php => HTTPSignature.php} | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) rename src/Util/{HTTPSig.php => HTTPSignature.php} (99%) diff --git a/doc/Addons.md b/doc/Addons.md index 090d5a9d77..3241ddc0df 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -362,7 +362,6 @@ Called when a magic-auth was successful. Hook data: 'visitor' => array with the contact record of the visitor 'url' => the query string - 'session' => $_SESSION array Current JavaScript hooks ------------- diff --git a/index.php b/index.php index c0290dff4d..f65867feb6 100644 --- a/index.php +++ b/index.php @@ -147,7 +147,7 @@ if ((x($_GET,'zrl')) && $a->mode == App::MODE_NORMAL) { if ((x($_GET,'owt')) && $a->mode == App::MODE_NORMAL) { $token = $_GET['owt']; $a->query_string = Profile::stripQueryParam($a->query_string, 'owt'); - Profile::owtInit($token); + Profile::openWebAuthInit($token); } /** diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 9741f2a74d..8d2045221f 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -1052,7 +1052,7 @@ class Profile * * @param string $token */ - public static function owtInit($token) + public static function openWebAuthInit($token) { $a = get_app(); @@ -1084,19 +1084,17 @@ class Profile $arr = [ 'visitor' => $visitor, - 'url' => $a->query_string, - 'session' => $_SESSION + 'url' => $a->query_string ]; /** * @hooks magic_auth_success * Called when a magic-auth was successful. * * \e array \b visitor * * \e string \b url - * * \e array \b session */ Addon::callHooks('magic_auth_success', $arr); - $a->contact = $visitor; + $a->contact = $arr['visitor']; info(L10n::t('OpenWebAuth: %1$s welcomes %2$s', $a->get_hostname(), $visitor['name'])); diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 86e9e44d8b..aaf0348eda 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -6,7 +6,7 @@ namespace Friendica\Module; use Friendica\BaseModule; use Friendica\Model\Contact; -use Friendica\Util\HTTPSig; +use Friendica\Util\HTTPSignature; use Friendica\Util\Network; use dba; @@ -76,7 +76,7 @@ class Magic extends BaseModule $headers['X-Open-Web-Auth'] = random_string(); // Create a header that is signed with the local users private key. - $headers = HTTPSig::createSig( + $headers = HTTPSignature::createSig( '', $headers, $user['prvkey'], diff --git a/src/Module/Owa.php b/src/Module/Owa.php index 6c580704f7..13594a3ea0 100644 --- a/src/Module/Owa.php +++ b/src/Module/Owa.php @@ -9,7 +9,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Verify; -use Friendica\Util\HTTPSig; +use Friendica\Util\HTTPSignature; use dba; @@ -39,7 +39,7 @@ class Owa extends BaseModule continue; } - $sigblock = HTTPSig::parseSigheader($_SERVER[$head]); + $sigblock = HTTPSignature::parseSigheader($_SERVER[$head]); if ($sigblock) { $keyId = $sigblock['keyId']; diff --git a/src/Util/HTTPSig.php b/src/Util/HTTPSignature.php similarity index 99% rename from src/Util/HTTPSig.php rename to src/Util/HTTPSignature.php index b78cca8964..d6152075e4 100644 --- a/src/Util/HTTPSig.php +++ b/src/Util/HTTPSignature.php @@ -19,7 +19,7 @@ use dba; * @see https://tools.ietf.org/html/draft-cavage-http-signatures-07 */ -class HTTPSig +class HTTPSignature { /** * @brief RFC5843 -- 2.39.5