Auth: Log login/logout activities to the audit log

refs #2563
This commit is contained in:
Johannes Meyer 2018-04-16 16:19:03 +02:00 committed by Eric Lippmann
parent 9da9f1237d
commit 3f66bd7437
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@ namespace Icinga\Authentication;
use Exception; use Exception;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Application\Hook\AuditHook;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Authentication\User\ExternalBackend; use Icinga\Authentication\User\ExternalBackend;
@ -164,6 +165,7 @@ class Auth
if ($persist) { if ($persist) {
$this->persistCurrentUser(); $this->persistCurrentUser();
} }
AuditHook::logActivity('login', 'User {{username}} logged in', ['username' => $user->getUsername()]);
} }
/** /**
@ -362,6 +364,7 @@ class Auth
*/ */
public function removeAuthorization() public function removeAuthorization()
{ {
AuditHook::logActivity('logout', 'User {{username}} logged out', ['username' => $this->user->getUsername()]);
$this->user = null; $this->user = null;
Session::getSession()->purge(); Session::getSession()->purge();
} }