Skip to content

Commit

Permalink
feat(ZMS-2778): Monitor logged in sessions by scope and department (#651
Browse files Browse the repository at this point in the history
)

* feat(ZMS-2778): Add three queries to status to monitor active sessions

* feat(ZMS-2778): Update three queries to status to monitor active sessions

* feat(ZMS-2778): Update three queries to status to monitor active sessions

* feat(ZMS-2778): Add token session duration to expiry.

* feat(ZMS-2778): Add to expiry to user table.

* feat(ZMS-2778): Change status query and fix tests

* feat(ZMS-2778): Fix tests

* feat(ZMS-2778): Fix tests

* feat(ZMS-2778): Fix tests

* feat(ZMS-2778): Add update sessionExpiry to updateEntityAuthkey
  • Loading branch information
ThomasAFink authored Oct 24, 2024
1 parent e7e1930 commit 2b1a93c
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 112 deletions.
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

0 comments on commit 2b1a93c

Please sign in to comment.