Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ZMS-2778): Monitor logged in sessions by scope and department #651

Merged
1 change: 1 addition & 0 deletions zmsapi/src/Zmsapi/WorkstationLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static function getLoggedInWorkstation($request, $entity, $resolveReferen
$useraccount->id,
$useraccount->password,
\App::getNow(),
(new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION),
$resolveReferences
);

Expand Down
3 changes: 3 additions & 0 deletions zmsapi/src/Zmsapi/WorkstationOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected function getLoggedInWorkstationByOidc($request, $entity, $resolveRefer
$entity->id,
$request->getHeaderLine('X-Authkey'),
\App::getNow(),
(new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION),
$resolveReferences
);
return $workstation;
Expand All @@ -73,12 +74,14 @@ protected function writeOAuthWorkstation(UseraccountEntity $entity, $state, $res
$useraccount->getId(),
$entity->password,
\App::getNow(),
(new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION),
$resolveReferences
);
$workstation = $query->updateEntityAuthkey(
$useraccount->getId(),
$entity->password,
$state,
(new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION),
$resolveReferences
);
return $workstation;
Expand Down
2 changes: 1 addition & 1 deletion zmsapi/tests/Zmsapi/WorkstationGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testRendering()
public function testReadWorkstationByXAuthKey()
{
$workstation = (new \BO\Zmsdb\Workstation)
->writeEntityLoginByName(static::$loginName, md5(static::$authKey), \App::getNow(), 1);
->writeEntityLoginByName(static::$loginName, md5(static::$authKey), \App::getNow(), (new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION), 1);
$logInHash = (new \BO\Zmsdb\Workstation)->readLoggedInHashByName($workstation->getUseraccount()->id);
$response = $this->render([], [
'__header' => [
Expand Down
2 changes: 1 addition & 1 deletion zmsapi/tests/Zmsapi/WorkstationUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testOveragedLogin()
$this->expectExceptionCode(200);

$entity = (new \BO\Zmsdb\Workstation)
->writeEntityLoginByName(static::$loginName, static::$authKey, \App::getNow(), 2);
->writeEntityLoginByName(static::$loginName, static::$authKey, \App::getNow(), (new \DateTime())->setTimestamp(time() + \App::SESSION_DURATION), 2);
$entity->scope['id'] = self::SCOPEID;
$entity->name = self::PLACE;
(new \BO\Zmsdb\Workstation)->updateEntity($entity, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `nutzer`
ADD COLUMN `sessionExpiry` DATETIME DEFAULT NULL;
6 changes: 5 additions & 1 deletion zmsdb/src/Zmsdb/Query/Workstation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Workstation extends Base implements MappingInterface
'. self::TABLE .'
SET
`SessionID`=?,
`sessionExpiry`=?,
`Datum`=?,
`lastUpdate`=?,
`Arbeitsplatznr`="",
Expand All @@ -33,6 +34,7 @@ class Workstation extends Base implements MappingInterface
'. self::TABLE .'
SET
`SessionID`=?,
`sessionExpiry`=?,
`Datum`=?,
`Arbeitsplatznr`="",
`aufrufzusatz`="",
Expand All @@ -56,6 +58,7 @@ class Workstation extends Base implements MappingInterface
'. self::TABLE .'
SET
`SessionID`="",
`sessionExpiry`=NULL,
`StandortID`=0,
`Datum`="0000-00-00",
`Arbeitsplatznr`="",
Expand All @@ -78,7 +81,8 @@ class Workstation extends Base implements MappingInterface
UPDATE
'. self::TABLE .'
SET
`SessionID`=?
`SessionID`=?,
`sessionExpiry`=?
WHERE
`Name`= ? AND
`Passworthash` = ?
Expand Down
Loading
Loading