Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(websso) remove exception when REMOTE_USER does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
wtermellil committed Oct 28, 2022
1 parent f9efb6d commit 3c28e12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public function authenticateOrFail(LoginRequest $request): void
{
$this->info('Authenticate the user');
$this->ipIsAllowToConnect($request->clientIp);
$this->validateLoginAttributeOrFail();
}

/**
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/EventSubscriber/WebSSOEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
}
}

/**
Expand Down

0 comments on commit 3c28e12

Please sign in to comment.