refactor(federation): omit app argument for error messages

As federation is an app, the LoggerInterface instance is ScopedPsrLogger and will set it.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
pull/53676/head
Daniel Kesselberg 6 months ago
parent 3fa81d0dc1
commit 2a0cb8d37d
No known key found for this signature in database
GPG Key ID: 4A81C29F63464E8F
  1. 7
      apps/federation/lib/BackgroundJob/GetSharedSecret.php
  2. 8
      apps/federation/lib/BackgroundJob/RequestSharedSecret.php
  3. 10
      apps/federation/lib/Controller/OCSAuthAPIController.php
  4. 1
      apps/federation/lib/SyncJob.php
  5. 1
      apps/federation/lib/TrustedServers.php

@ -115,9 +115,9 @@ class GetSharedSecret extends Job {
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
$this->logger->info($target . ' refused to exchange a shared secret with you.', ['app' => 'federation']);
$this->logger->info($target . ' refused to exchange a shared secret with you.');
} else {
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
}
} catch (RequestException $e) {
$status = -1; // There is no status code if we could not connect
@ -149,8 +149,7 @@ class GetSharedSecret extends Job {
);
} else {
$this->logger->error(
'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body,
['app' => 'federation']
'remote server "' . $target . '"" does not return a valid shared secret. Received data: ' . $body
);
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
}

@ -126,16 +126,16 @@ class RequestSharedSecret extends Job {
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
$this->logger->info($target . ' refused to ask for a shared secret.', ['app' => 'federation']);
$this->logger->info($target . ' refused to ask for a shared secret.');
} else {
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']);
$this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage());
}
} catch (RequestException $e) {
$status = -1; // There is no status code if we could not connect
$this->logger->info('Could not connect to ' . $target, ['app' => 'federation']);
$this->logger->info('Could not connect to ' . $target);
} catch (\Throwable $e) {
$status = Http::STATUS_INTERNAL_SERVER_ERROR;
$this->logger->error($e->getMessage(), ['app' => 'federation', 'exception' => $e]);
$this->logger->error($e->getMessage(), ['exception' => $e]);
}
// if we received a unexpected response we try again later

@ -98,7 +98,7 @@ class OCSAuthAPIController extends OCSController {
public function requestSharedSecret(string $url, string $token): DataResponse {
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
$this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']);
$this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret');
throw new OCSForbiddenException();
}
@ -107,8 +107,7 @@ class OCSAuthAPIController extends OCSController {
$localToken = $this->dbHandler->getToken($url);
if (strcmp($localToken, $token) > 0) {
$this->logger->info(
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
['app' => 'federation']
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.'
);
throw new OCSForbiddenException();
}
@ -141,7 +140,7 @@ class OCSAuthAPIController extends OCSController {
public function getSharedSecret(string $url, string $token): DataResponse {
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret');
throw new OCSForbiddenException();
}
@ -149,8 +148,7 @@ class OCSAuthAPIController extends OCSController {
$this->throttler->registerAttempt('federationSharedSecret', $this->request->getRemoteAddress());
$expectedToken = $this->dbHandler->getToken($url);
$this->logger->error(
'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret',
['app' => 'federation']
'remote server (' . $url . ') didn\'t send a valid token (got "' . $token . '" but expected "' . $expectedToken . '") while getting shared secret'
);
throw new OCSForbiddenException();
}

@ -27,7 +27,6 @@ class SyncJob extends TimedJob {
$this->syncService->syncThemAll(function ($url, $ex): void {
if ($ex instanceof \Exception) {
$this->logger->error("Error while syncing $url.", [
'app' => 'fed-sync',
'exception' => $ex,
]);
}

@ -169,7 +169,6 @@ class TrustedServers {
}
} catch (\Exception $e) {
$this->logger->error('No Nextcloud server.', [
'app' => 'federation',
'exception' => $e,
]);
return false;

Loading…
Cancel
Save