]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/HTTPSignature.php
Fix goaway url when login failed + using info to display message
[friendica.git] / src / Util / HTTPSignature.php
index aba280cf1dc57fd54205a915e7bfe6db21b8b374..234d896078a6b1710df1885348ad25fdece2e610 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Database\DBA;
 use Friendica\Model\User;
+use Friendica\Model\APContact;
 use Friendica\Protocol\ActivityPub;
 
 /**
@@ -25,6 +26,13 @@ use Friendica\Protocol\ActivityPub;
 class HTTPSignature
 {
        // See draft-cavage-http-signatures-08
+       /**
+        * @brief Verifies a magic request
+        *
+        * @param $key
+        *
+        * @return array with verification data
+        */
        public static function verifyMagic($key)
        {
                $headers   = null;
@@ -257,10 +265,17 @@ class HTTPSignature
                return '';
        }
 
-       /**
+       /*
         * Functions for ActivityPub
         */
 
+       /**
+        * @brief Transmit given data to a target for a user
+        *
+        * @param $data
+        * @param $target
+        * @param $uid
+        */
        public static function transmit($data, $target, $uid)
        {
                $owner = User::getOwnerDataById($uid);
@@ -293,6 +308,14 @@ class HTTPSignature
                logger('Transmit to ' . $target . ' returned ' . $return_code);
        }
 
+       /**
+        * @brief Gets a signer from a given HTTP request
+        *
+        * @param $content
+        * @param $http_headers
+        *
+        * @return signer string
+        */
        public static function getSigner($content, $http_headers)
        {
                $object = json_decode($content, true);
@@ -389,16 +412,24 @@ class HTTPSignature
                return $key['url'];
        }
 
+       /**
+        * @brief fetches a key for a given id and actor
+        *
+        * @param $id
+        * @param $actor
+        *
+        * @return array with actor url and public key
+        */
        private static function fetchKey($id, $actor)
        {
                $url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
 
-               $profile = ActivityPub::fetchprofile($url);
+               $profile = APContact::getByURL($url);
                if (!empty($profile)) {
                        logger('Taking key from id ' . $id, LOGGER_DEBUG);
                        return ['url' => $url, 'pubkey' => $profile['pubkey']];
                } elseif ($url != $actor) {
-                       $profile = ActivityPub::fetchprofile($actor);
+                       $profile = APContact::getByURL($actor);
                        if (!empty($profile)) {
                                logger('Taking key from actor ' . $actor, LOGGER_DEBUG);
                                return ['url' => $actor, 'pubkey' => $profile['pubkey']];