summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-06-12 16:36:50 -0100
committerGitHub <noreply@github.com>2019-06-12 16:36:50 -0100
commit3f55e9e93c5313c81d1cff0d66827c643f6fb712 (patch)
tree69cbb1edecb689e34a293ad9630831228868a653
parent86a79d7cfc77980ecb9cc5d52a538df8ebc99bc6 (diff)
parent37dd4f763ecdf7cea43587e79ef32242e987d4f3 (diff)
Merge pull request #579 from nextcloud/misc/more-loggin
more loggin
-rw-r--r--lib/Controller/ActivityPubController.php2
-rw-r--r--lib/Model/ActivityPub/ACore.php12
-rw-r--r--lib/Service/CacheActorService.php8
-rw-r--r--lib/Service/CurlService.php4
-rw-r--r--lib/Service/SignatureService.php10
-rw-r--r--lib/Service/StreamQueueService.php5
6 files changed, 28 insertions, 13 deletions
diff --git a/lib/Controller/ActivityPubController.php b/lib/Controller/ActivityPubController.php
index a1d50d22..c752fb85 100644
--- a/lib/Controller/ActivityPubController.php
+++ b/lib/Controller/ActivityPubController.php
@@ -36,8 +36,8 @@ use daita\MySmallPhpTools\Traits\TStringTools;
use Exception;
use OC\AppFramework\Http;
use OCA\Social\AppInfo\Application;
-use OCA\Social\Exceptions\SignatureIsGoneException;
use OCA\Social\Exceptions\ItemUnknownException;
+use OCA\Social\Exceptions\SignatureIsGoneException;
use OCA\Social\Exceptions\UrlCloudException;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\FediverseService;
diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php
index 14d55973..89515e11 100644
--- a/lib/Model/ActivityPub/ACore.php
+++ b/lib/Model/ActivityPub/ACore.php
@@ -279,21 +279,23 @@ class ACore extends Item implements JsonSerializable {
*/
public function checkOrigin($id) {
$host = parse_url($id, PHP_URL_HOST);
- if ($this->getRoot()
- ->getOrigin() === $host) {
+ $origin = $this->getRoot()
+ ->getOrigin();
+
+ if ($origin === $host) {
return;
}
- throw new InvalidOriginException();
+ throw new InvalidOriginException('ACore::checkOrigin - id: ' . $id . ' - origin: ' . $origin);
}
/**
- * @deprecated
- *
* @param string $url
*
* @throws ActivityCantBeVerifiedException
+ * @deprecated
+ *
*/
public function verify(string $url) {
// TODO - Compare this with checkOrigin() - and delete this method.
diff --git a/lib/Service/CacheActorService.php b/lib/Service/CacheActorService.php
index d900741c..2aed18e6 100644
--- a/lib/Service/CacheActorService.php
+++ b/lib/Service/CacheActorService.php
@@ -144,7 +144,9 @@ class CacheActorService {
}
if ($id !== $actor->getId()) {
- throw new InvalidOriginException();
+ throw new InvalidOriginException(
+ 'CacheActorService::getFromId - id: ' . $id . ' - actorId: ' . $actor->getId()
+ );
}
$actor->setAccount($actor->getPreferredUsername() . '@' . $this->get('_host', $object));
@@ -227,8 +229,8 @@ class CacheActorService {
/**
- * @throws Exception
* @return int
+ * @throws Exception
*/
public function missingCacheRemoteActors(): int {
// TODO - looking for missing cache remote actors...
@@ -246,8 +248,8 @@ class CacheActorService {
/**
- * @throws Exception
* @return int
+ * @throws Exception
*/
public function manageCacheRemoteActors(): int {
$update = $this->cacheActorsRequest->getRemoteActorsToUpdate();
diff --git a/lib/Service/CurlService.php b/lib/Service/CurlService.php
index 01eabb30..ef12a93e 100644
--- a/lib/Service/CurlService.php
+++ b/lib/Service/CurlService.php
@@ -175,7 +175,9 @@ class CurlService {
}
if (strtolower($actor->getId()) !== strtolower($id)) {
- throw new InvalidOriginException();
+ throw new InvalidOriginException(
+ 'CurlService::retrieveAccount - id: ' . $id . ' - actorId: ' . $actor->getId()
+ );
}
return $actor;
diff --git a/lib/Service/SignatureService.php b/lib/Service/SignatureService.php
index d7e2e0d8..ac0cdc1e 100644
--- a/lib/Service/SignatureService.php
+++ b/lib/Service/SignatureService.php
@@ -126,7 +126,7 @@ class SignatureService {
public function generateKeys(Person &$actor) {
$res = openssl_pkey_new(
[
- "digest_alg" => "rsa",
+ "digest_alg" => "rsa",
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
]
@@ -374,6 +374,10 @@ class SignatureService {
$entries = explode(',', $signatureHeader);
foreach ($entries as $entry) {
+ if ($entry === '' || !strpos($entry, '=')) {
+ continue;
+ }
+
list($k, $v) = explode('=', $entry, 2);
preg_match('/"([^"]+)"/', $v, $varr);
$v = trim($varr[0], '"');
@@ -422,7 +426,9 @@ class SignatureService {
return $host;
}
- throw new InvalidOriginException();
+ throw new InvalidOriginException(
+ 'SignatureService::getKeyOrigin - host: ' . $host . ' - id: ' . $id
+ );
}
diff --git a/lib/Service/StreamQueueService.php b/lib/Service/StreamQueueService.php
index 63a59beb..de4edb61 100644
--- a/lib/Service/StreamQueueService.php
+++ b/lib/Service/StreamQueueService.php
@@ -320,7 +320,10 @@ class StreamQueueService {
$object->setOrigin($origin, SignatureService::ORIGIN_REQUEST, time());
if ($object->getId() !== $item->getUrl()) {
- throw new InvalidOriginException();
+ throw new InvalidOriginException(
+ 'StreamQueueService::cacheItem - objectId: ' . $object->getId() . ' - itemUrl: '
+ . $item->getUrl()
+ );
}
if ($object->getType() !== Note::TYPE) {