Skip to content

Commit

Permalink
Correctly validate api request token expiration date for access
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Mar 2, 2024
1 parent 127e830 commit 96c3d0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Domain/User/Service/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public function getUserIdByApiToken(Request $request) : ?int
return null;
}

if ($this->isValidAuthToken($apiToken) === false) {
return null;
}

return $this->userApi->findByToken($apiToken)?->getId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public function __construct(

public function __invoke(Request $request) : ?Response
{
$requestedUser = $this->userApi->findUserByName((string)$request->getRouteParameters()['username']);
$requestedUsername = (string)$request->getRouteParameters()['username'];

$requestedUser = $this->userApi->findUserByName($requestedUsername);
if ($requestedUser === null) {
return Response::createNotFound();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public function __construct(

public function __invoke(Request $request) : ?Response
{
$requestedUser = $this->userApi->findUserByName((string)$request->getRouteParameters()['username']);
$requestedUsername = (string)$request->getRouteParameters()['username'];

$requestedUser = $this->userApi->findUserByName($requestedUsername);
if ($requestedUser === null) {
return Response::createNotFound();
}
Expand Down

0 comments on commit 96c3d0d

Please sign in to comment.