diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-12 17:14:25 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-10-12 22:07:04 +0200 |
commit | 49ff48fcd3f07c229a0439748cb1469e5d11c504 (patch) | |
tree | b6fb0e531e0b36920700124040056b92882263ae /lib/private/Authentication | |
parent | deb499d34e7e4760db22d250b4cb1449e981d98c (diff) | |
download | nextcloud-server-49ff48fcd3f07c229a0439748cb1469e5d11c504.tar.gz nextcloud-server-49ff48fcd3f07c229a0439748cb1469e5d11c504.zip |
Use PSR logger in authentication
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Authentication')
11 files changed, 54 insertions, 60 deletions
diff --git a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php index 0ab2dcf4837..b841f81555b 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php @@ -33,18 +33,18 @@ use OC\Authentication\Token\IToken; use OCP\Activity\IManager as IActvityManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class RemoteWipeActivityListener implements IEventListener { /** @var IActvityManager */ private $activityManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IActvityManager $activityManager, - ILogger $logger) { + LoggerInterface $logger) { $this->activityManager = $activityManager; $this->logger = $logger; } @@ -69,10 +69,9 @@ class RemoteWipeActivityListener implements IEventListener { try { $this->activityManager->publish($activity); } catch (BadMethodCallException $e) { - $this->logger->logException($e, [ + $this->logger->warning('could not publish activity', [ 'app' => 'core', - 'level' => ILogger::WARN, - 'message' => 'could not publish activity', + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php index 799c4ea4cf5..52698855bd5 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php @@ -32,12 +32,12 @@ use OC\Authentication\Events\RemoteWipeStarted; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IL10N; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory as IL10nFactory; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use Psr\Log\LoggerInterface; use function substr; class RemoteWipeEmailListener implements IEventListener { @@ -51,13 +51,13 @@ class RemoteWipeEmailListener implements IEventListener { /** @var IL10N */ private $l10n; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IMailer $mailer, IUserManager $userManager, IL10nFactory $l10nFactory, - ILogger $logger) { + LoggerInterface $logger) { $this->mailer = $mailer; $this->userManager = $userManager; $this->l10n = $l10nFactory->get('core'); @@ -85,9 +85,8 @@ class RemoteWipeEmailListener implements IEventListener { $this->getWipingStartedMessage($event, $user) ); } catch (Exception $e) { - $this->logger->logException($e, [ - 'message' => "Could not send remote wipe started email to <$uid>", - 'level' => ILogger::ERROR, + $this->logger->error("Could not send remote wipe started email to <$uid>", [ + 'exception' => $e, ]); } } elseif ($event instanceof RemoteWipeFinished) { @@ -107,9 +106,8 @@ class RemoteWipeEmailListener implements IEventListener { $this->getWipingFinishedMessage($event, $user) ); } catch (Exception $e) { - $this->logger->logException($e, [ - 'message' => "Could not send remote wipe finished email to <$uid>", - 'level' => ILogger::ERROR, + $this->logger->error("Could not send remote wipe finished email to <$uid>", [ + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php index 3b362336675..e1199814da5 100644 --- a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php @@ -29,8 +29,8 @@ namespace OC\Authentication\Listeners; use OC\Authentication\Token\Manager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\ILogger; use OCP\User\Events\UserDeletedEvent; +use Psr\Log\LoggerInterface; use Throwable; class UserDeletedTokenCleanupListener implements IEventListener { @@ -38,11 +38,11 @@ class UserDeletedTokenCleanupListener implements IEventListener { /** @var Manager */ private $manager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(Manager $manager, - ILogger $logger) { + LoggerInterface $logger) { $this->manager = $manager; $this->logger = $logger; } @@ -64,9 +64,8 @@ class UserDeletedTokenCleanupListener implements IEventListener { $this->manager->invalidateTokenById($uid, $token->getId()); } } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => 'Could not clean up auth tokens after user deletion: ' . $e->getMessage(), - 'error' => ILogger::ERROR, + $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Login/LoggedInCheckCommand.php b/lib/private/Authentication/Login/LoggedInCheckCommand.php index d2546a62d16..1848c5db09e 100644 --- a/lib/private/Authentication/Login/LoggedInCheckCommand.php +++ b/lib/private/Authentication/Login/LoggedInCheckCommand.php @@ -29,19 +29,17 @@ namespace OC\Authentication\Login; use OC\Authentication\Events\LoginFailed; use OC\Core\Controller\LoginController; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; -use OCP\IUserManager; +use Psr\Log\LoggerInterface; class LoggedInCheckCommand extends ALoginCommand { - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IEventDispatcher */ private $dispatcher; - /** @var IUserManager */ - private $userManager; - public function __construct(ILogger $logger, IEventDispatcher $dispatcher) { + public function __construct(LoggerInterface $logger, + IEventDispatcher $dispatcher) { $this->logger = $logger; $this->dispatcher = $dispatcher; } diff --git a/lib/private/Authentication/Login/UserDisabledCheckCommand.php b/lib/private/Authentication/Login/UserDisabledCheckCommand.php index e33853ef5bd..49762546bc4 100644 --- a/lib/private/Authentication/Login/UserDisabledCheckCommand.php +++ b/lib/private/Authentication/Login/UserDisabledCheckCommand.php @@ -26,19 +26,19 @@ declare(strict_types=1); namespace OC\Authentication\Login; use OC\Core\Controller\LoginController; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class UserDisabledCheckCommand extends ALoginCommand { /** @var IUserManager */ private $userManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IUserManager $userManager, - ILogger $logger) { + LoggerInterface $logger) { $this->userManager = $userManager; $this->logger = $logger; } diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php index 29bc4f6a2e1..89992dc2117 100644 --- a/lib/private/Authentication/LoginCredentials/Store.php +++ b/lib/private/Authentication/LoginCredentials/Store.php @@ -33,28 +33,25 @@ use OC\Authentication\Token\IProvider; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\LoginCredentials\ICredentials; use OCP\Authentication\LoginCredentials\IStore; -use OCP\ILogger; use OCP\ISession; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\Util; +use Psr\Log\LoggerInterface; class Store implements IStore { /** @var ISession */ private $session; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IProvider|null */ private $tokenProvider; - /** - * @param ISession $session - * @param ILogger $logger - * @param IProvider $tokenProvider - */ - public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { + public function __construct(ISession $session, + LoggerInterface $logger, + IProvider $tokenProvider = null) { $this->session = $session; $this->logger = $logger; $this->tokenProvider = $tokenProvider; diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index ee8a28d3cb0..a6a1af5a97a 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -39,8 +39,8 @@ use OC\Authentication\Exceptions\PasswordlessTokenException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class DefaultTokenProvider implements IProvider { @@ -53,7 +53,7 @@ class DefaultTokenProvider implements IProvider { /** @var IConfig */ private $config; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var ITimeFactory */ @@ -62,7 +62,7 @@ class DefaultTokenProvider implements IProvider { public function __construct(DefaultTokenMapper $mapper, ICrypto $crypto, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $time) { $this->mapper = $mapper; $this->crypto = $crypto; diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index df50da2f03a..38551e63b87 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -39,8 +39,8 @@ use OC\Cache\CappedMemoryCache; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class PublicKeyTokenProvider implements IProvider { /** @var PublicKeyTokenMapper */ @@ -52,10 +52,10 @@ class PublicKeyTokenProvider implements IProvider { /** @var IConfig */ private $config; - /** @var ILogger $logger */ + /** @var LoggerInterface */ private $logger; - /** @var ITimeFactory $time */ + /** @var ITimeFactory */ private $time; /** @var CappedMemoryCache */ @@ -64,7 +64,7 @@ class PublicKeyTokenProvider implements IProvider { public function __construct(PublicKeyTokenMapper $mapper, ICrypto $crypto, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $time) { $this->mapper = $mapper; $this->crypto = $crypto; diff --git a/lib/private/Authentication/Token/RemoteWipe.php b/lib/private/Authentication/Token/RemoteWipe.php index cab68357a01..b762073a8bc 100644 --- a/lib/private/Authentication/Token/RemoteWipe.php +++ b/lib/private/Authentication/Token/RemoteWipe.php @@ -28,13 +28,13 @@ declare(strict_types=1); namespace OC\Authentication\Token; +use Psr\Log\LoggerInterface; use function array_filter; use OC\Authentication\Events\RemoteWipeFinished; use OC\Authentication\Events\RemoteWipeStarted; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\WipeTokenException; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IUser; class RemoteWipe { @@ -45,12 +45,12 @@ class RemoteWipe { /** @var IEventDispatcher */ private $eventDispatcher; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IProvider $tokenProvider, IEventDispatcher $eventDispatcher, - ILogger $logger) { + LoggerInterface $logger) { $this->tokenProvider = $tokenProvider; $this->eventDispatcher = $eventDispatcher; $this->logger = $logger; diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 07e61175361..8e529ccbda8 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -27,8 +27,6 @@ declare(strict_types=1); namespace OC\Authentication\TwoFactorAuth; -use function array_diff; -use function array_filter; use BadMethodCallException; use Exception; use OC\Authentication\Exceptions\InvalidTokenException; @@ -39,11 +37,13 @@ use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IRegistry; use OCP\IConfig; -use OCP\ILogger; use OCP\ISession; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; +use function array_diff; +use function array_filter; class Manager { public const SESSION_UID_KEY = 'two_factor_auth_uid'; @@ -69,7 +69,7 @@ class Manager { /** @var IManager */ private $activityManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var TokenProvider */ @@ -84,9 +84,13 @@ class Manager { public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry, MandatoryTwoFactor $mandatoryTwoFactor, - ISession $session, IConfig $config, - IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider, - ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) { + ISession $session, + IConfig $config, + IManager $activityManager, + LoggerInterface $logger, + TokenProvider $tokenProvider, + ITimeFactory $timeFactory, + EventDispatcherInterface $eventDispatcher) { $this->providerLoader = $providerLoader; $this->providerRegistry = $providerRegistry; $this->mandatoryTwoFactor = $mandatoryTwoFactor; @@ -295,8 +299,7 @@ class Manager { try { $this->activityManager->publish($activity); } catch (BadMethodCallException $e) { - $this->logger->warning('could not publish activity', ['app' => 'core']); - $this->logger->logException($e, ['app' => 'core']); + $this->logger->warning('could not publish activity', ['app' => 'core', 'exception' => $e]); } } diff --git a/lib/private/Authentication/WebAuthn/Manager.php b/lib/private/Authentication/WebAuthn/Manager.php index 4415badc9b0..ce70c54bf11 100644 --- a/lib/private/Authentication/WebAuthn/Manager.php +++ b/lib/private/Authentication/WebAuthn/Manager.php @@ -35,8 +35,8 @@ use OC\Authentication\WebAuthn\Db\PublicKeyCredentialEntity; use OC\Authentication\WebAuthn\Db\PublicKeyCredentialMapper; use OCP\AppFramework\Db\DoesNotExistException; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Webauthn\AttestationStatement\AttestationObjectLoader; use Webauthn\AttestationStatement\AttestationStatementSupportManager; use Webauthn\AttestationStatement\NoneAttestationStatementSupport; @@ -63,7 +63,7 @@ class Manager { /** @var PublicKeyCredentialMapper */ private $credentialMapper; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IConfig */ @@ -72,7 +72,7 @@ class Manager { public function __construct( CredentialRepository $repository, PublicKeyCredentialMapper $credentialMapper, - ILogger $logger, + LoggerInterface $logger, IConfig $config ) { $this->repository = $repository; |