diff --git a/src/Core/Security/Authentication/Infrastructure/Provider/WebSSO.php b/src/Core/Security/Authentication/Infrastructure/Provider/WebSSO.php index e07081ab7d7..3edc7ba4af5 100644 --- a/src/Core/Security/Authentication/Infrastructure/Provider/WebSSO.php +++ b/src/Core/Security/Authentication/Infrastructure/Provider/WebSSO.php @@ -162,7 +162,6 @@ public function authenticateOrFail(LoginRequest $request): void { $this->info('Authenticate the user'); $this->ipIsAllowToConnect($request->clientIp); - $this->validateLoginAttributeOrFail(); } /** @@ -212,7 +211,7 @@ public function ipIsAllowToConnect(string $ipAddress): void /** * Validate that login attribute is defined in server environment variables */ - public function validateLoginAttributeOrFail(): void + public function loginAttributeIsValid(): bool { /** @var CustomConfiguration $customConfiguration */ $customConfiguration = $this->getConfiguration()->getCustomConfiguration(); @@ -221,8 +220,11 @@ public function validateLoginAttributeOrFail(): void $this->error('login header attribute not found in server environment', [ 'login_header_attribute' => $customConfiguration->getLoginHeaderAttribute() ]); - throw new InvalidArgumentException('Missing Login Attribute'); + + return false; } + + return true; } /** diff --git a/src/EventSubscriber/WebSSOEventSubscriber.php b/src/EventSubscriber/WebSSOEventSubscriber.php index dfe41c2b904..f44e7603a96 100644 --- a/src/EventSubscriber/WebSSOEventSubscriber.php +++ b/src/EventSubscriber/WebSSOEventSubscriber.php @@ -121,13 +121,15 @@ public function loginWebSSOUser(RequestEvent $event): void } $this->info('Starting authentication with WebSSO'); - $provider->authenticateOrFail( - LoginRequest::createForSSO($request->getClientIp()) - ); + if ($provider->loginAttributeIsValid()) { + $provider->authenticateOrFail( + LoginRequest::createForSSO($request->getClientIp()) + ); - $user = $provider->findUserOrFail(); - $this->createSession($request, $provider); - $this->info('Authenticated successfully', ['user' => $user->getAlias()]); + $user = $provider->findUserOrFail(); + $this->createSession($request, $provider); + $this->info('Authenticated successfully', ['user' => $user->getAlias()]); + } } /**