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 Nov 2, 2022
1 parent f9efb6d commit a26e8cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ 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');
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/EventSubscriber/WebSSOEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ public function loginWebSSOUser(RequestEvent $event): void
}

$this->info('Starting authentication with WebSSO');
$provider->authenticateOrFail(
LoginRequest::createForSSO($request->getClientIp())
);
try {
$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()]);
} catch (\InvalidArgumentException $exception) {
$this->info($exception->getMessage());
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/EventSubscriber/WebSSOEventSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
->method('start');

$this->subscriber->loginWebSSOUser($this->event);
})->throws(\InvalidArgumentException::class, 'Missing Login Attribute');
});

it('should throw an exception when login matching regexp returns an invalid result', function () {
$this->request->cookies = new InputBag();
Expand Down

0 comments on commit a26e8cf

Please sign in to comment.