port hubzillas OpenWebAuth - HTTPSignature - comment out some ActivityPub parts

This commit is contained in:
rabuzarus 2018-06-20 19:05:33 +02:00
parent 863a49d8e7
commit 1ab3f7bfc8

View file

@ -24,6 +24,9 @@ class HTTPSignature
/** /**
* @brief RFC5843 * @brief RFC5843
* *
* Disabled until Friendica's ActivityPub implementation
* is ready.
*
* @see https://tools.ietf.org/html/rfc5843 * @see https://tools.ietf.org/html/rfc5843
* *
* @param string $body The value to create the digest for * @param string $body The value to create the digest for
@ -32,15 +35,15 @@ class HTTPSignature
* *
* @return string The generated digest of $body * @return string The generated digest of $body
*/ */
public static function generateDigest($body, $set = true) // public static function generateDigest($body, $set = true)
{ // {
$digest = base64_encode(hash('sha256', $body, true)); // $digest = base64_encode(hash('sha256', $body, true));
//
if($set) { // if($set) {
header('Digest: SHA-256=' . $digest); // header('Digest: SHA-256=' . $digest);
} // }
return $digest; // return $digest;
} // }
// See draft-cavage-http-signatures-08 // See draft-cavage-http-signatures-08
public static function verify($data, $key = '') public static function verify($data, $key = '')
@ -178,13 +181,13 @@ class HTTPSignature
private static function getActivitypubKey($id) private static function getActivitypubKey($id)
{ {
if (strpos($id, 'acct:') === 0) { if (strpos($id, 'acct:') === 0) {
$x = dba::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]); $contact = dba::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]);
} else { } else {
$x = dba::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']); $contact = dba::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']);
} }
if (DBM::is_result($x)) { if (DBM::is_result($contact)) {
return $x['pubkey']; return $contact['pubkey'];
} }
if(function_exists('as_fetch')) { if(function_exists('as_fetch')) {
@ -253,7 +256,10 @@ class HTTPSignature
if ($head) { if ($head) {
foreach ($head as $k => $v) { foreach ($head as $k => $v) {
if ($send_headers) { if ($send_headers) {
header($k . ': ' . $v); // This is for ActivityPub implementation.
// Since the Activity Pub implementation isn't
// ready at the moment, we comment it out.
// header($k . ': ' . $v);
} else { } else {
$return_headers[] = $k . ': ' . $v; $return_headers[] = $k . ': ' . $v;
} }
@ -261,7 +267,10 @@ class HTTPSignature
} }
if ($send_headers) { if ($send_headers) {
header($sighead); // This is for ActivityPub implementation.
// Since the Activity Pub implementation isn't
// ready at the moment, we comment it out.
// header($sighead);
} else { } else {
$return_headers[] = $sighead; $return_headers[] = $sighead;
} }