use Friendica\Core\Config;
use Friendica\Database\DBA;
use Friendica\Model\User;
+use Friendica\Model\APContact;
use Friendica\Protocol\ActivityPub;
/**
*
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Web/HTTPSig.php
*
+ * Other parts of the code for HTTP signing are taken from the Osada project.
+ * https://framagit.org/macgirvin/osada
+ *
* @see https://tools.ietf.org/html/draft-cavage-http-signatures-07
*/
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;
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);
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);
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']];