X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FHTTPSignature.php;h=234d896078a6b1710df1885348ad25fdece2e610;hb=3ecabe0291b159d163ad315b66f51b6d741d879e;hp=aba280cf1dc57fd54205a915e7bfe6db21b8b374;hpb=834422d52f0b34fb088f79ac2704c3d514802d8e;p=friendica.git diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index aba280cf1d..234d896078 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -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']];