From 5e8bb477ab3d246caf0b01c5a6ab3611d11f0ace Mon Sep 17 00:00:00 2001 From: Wilco Louwerse Date: Thu, 21 Mar 2024 14:59:53 +0100 Subject: [PATCH] With ApiKey for auth, make sure we set application in session correctly --- api/src/Security/ApiKeyAuthenticator.php | 2 +- api/src/Service/ApplicationService.php | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/api/src/Security/ApiKeyAuthenticator.php b/api/src/Security/ApiKeyAuthenticator.php index a5c04a7f0..c4d0ce265 100644 --- a/api/src/Security/ApiKeyAuthenticator.php +++ b/api/src/Security/ApiKeyAuthenticator.php @@ -101,7 +101,7 @@ public function authenticate(Request $request): PassportInterface } // Set apiKey Application id in session - $this->session->set('apiKeyApplication', $application->getId()->toString()); + $this->session->set('application', $application->getId()->toString()); // Set organization id and user id in session $this->session->set('user', $user->getId()->toString()); diff --git a/api/src/Service/ApplicationService.php b/api/src/Service/ApplicationService.php index 6536ff90c..a83d16b70 100644 --- a/api/src/Service/ApplicationService.php +++ b/api/src/Service/ApplicationService.php @@ -44,15 +44,6 @@ public function getApplication(): Application } } - // If an api-key is used for authentication we already know which application is used - if ($this->session->has('apiKeyApplication')) { - $application = $this->entityManager->getRepository('App:Application')->findOneBy(['id' => $this->session->get('apiKeyApplication')]); - if ($application !== null) { - $this->session->set('application', $application->getId()->toString()); - return $application; - } - } - // Find application using the publicKey $public = ($this->request->headers->get('public') ?? $this->request->query->get('public')); if (empty($public) === false) {