From 45a928866fe93db4ec37cddef302f69208c39844 Mon Sep 17 00:00:00 2001 From: Remy Blom Date: Wed, 19 Jun 2024 11:22:11 +0200 Subject: [PATCH] =?UTF-8?q?fix=20for:=20=E2=80=98autofill=20username?= =?UTF-8?q?=E2=80=99=20that=20resulted=20in=20a=20WRONGUSERPASS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/core/src/Controller/Login.php | 64 +++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/core/src/Controller/Login.php b/modules/core/src/Controller/Login.php index 4e6f4e63b4..d95f021287 100644 --- a/modules/core/src/Controller/Login.php +++ b/modules/core/src/Controller/Login.php @@ -115,6 +115,37 @@ public function loginuserpass(Request $request): Response } + /** + * This page shows a username/password/organization login form, and passes information from + * into the \SimpleSAML\Module\core\Auth\UserPassBase class, which is a generic class for + * username/password/organization authentication. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Response + */ + public function loginuserpassorg(Request $request): Response + { + // Retrieve the authentication state + if (!$request->query->has('AuthState')) { + throw new Error\BadRequest('Missing AuthState parameter.'); + } + $authStateId = $request->query->get('AuthState'); + $this->authState::validateStateId($authStateId); + + $state = $this->authState::loadState($authStateId, UserPassOrgBase::STAGEID); + + /** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $source */ + $source = $this->authSource::getById($state[UserPassOrgBase::AUTHID]); + if ($source === null) { + throw new BuiltinException( + 'Could not find authentication source with id ' . $state[UserPassOrgBase::AUTHID], + ); + } + + return $this->handleLogin($request, $source, $state); + } + + /** * This method handles the generic part for both loginuserpass and loginuserpassorg * @@ -146,7 +177,7 @@ private function handleLogin(Request $request, UserPassBase|UserPassOrgBase $sou } if ($organizations === null || $organization !== '') { - if (!empty($username) || !empty($password)) { + if (!empty($password)) { $cookies = []; $httpUtils = new Utils\HTTP(); $sameSiteNone = $httpUtils->canSetSamesiteNone() ? Cookie::SAMESITE_NONE : null; @@ -303,37 +334,6 @@ private function handleLogin(Request $request, UserPassBase|UserPassOrgBase $sou } - /** - * This page shows a username/password/organization login form, and passes information from - * into the \SimpleSAML\Module\core\Auth\UserPassBase class, which is a generic class for - * username/password/organization authentication. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @return \Symfony\Component\HttpFoundation\Response - */ - public function loginuserpassorg(Request $request): Response - { - // Retrieve the authentication state - if (!$request->query->has('AuthState')) { - throw new Error\BadRequest('Missing AuthState parameter.'); - } - $authStateId = $request->query->get('AuthState'); - $this->authState::validateStateId($authStateId); - - $state = $this->authState::loadState($authStateId, UserPassOrgBase::STAGEID); - - /** @var \SimpleSAML\Module\core\Auth\UserPassOrgBase $source */ - $source = $this->authSource::getById($state[UserPassOrgBase::AUTHID]); - if ($source === null) { - throw new BuiltinException( - 'Could not find authentication source with id ' . $state[UserPassOrgBase::AUTHID], - ); - } - - return $this->handleLogin($request, $source, $state); - } - - /** * @param string $name The name for the cookie * @param string $value The value for the cookie