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

fix(websso) remove exception when REMOTE_USER does not exist #12047

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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');
wtermellil marked this conversation as resolved.
Show resolved Hide resolved
}
}
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