From 6a5b9032c0a4c8e3a103ddc6220ffe9f51379d10 Mon Sep 17 00:00:00 2001 From: Midah Pasche Date: Sat, 1 Feb 2025 07:48:05 +0100 Subject: [PATCH 1/2] add horde_auth_fallback driver in Horde_Core_Factory_Base::_create --- lib/Horde/Core/Factory/Auth.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Horde/Core/Factory/Auth.php b/lib/Horde/Core/Factory/Auth.php index 6a582fb8b..6f91e528f 100644 --- a/lib/Horde/Core/Factory/Auth.php +++ b/lib/Horde/Core/Factory/Auth.php @@ -1,4 +1,5 @@ _create($params['primary_driver']['driver'], $params['primary_driver']['params']); + } + if (!empty($params['fallback_driver'])) { + $params['fallback_driver'] = $this->_create($params['fallback_driver']['driver'], $params['fallback_driver']['params']); + } + break; + case 'horde_auth_cyrsql': $imap_config = array( 'hostspec' => empty($params['cyrhost']) ? null : $params['cyrhost'], @@ -188,5 +200,4 @@ protected function _create($driver, $orig_params = null) return $auth_ob; } - } From a13026c6219b8ec16d63696a54ad021a904580e2 Mon Sep 17 00:00:00 2001 From: Midah Pasche Date: Mon, 3 Feb 2025 09:33:24 +0100 Subject: [PATCH 2/2] allow to use 'authenticate' without logging in --- lib/Horde/Core/Auth/Application.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Horde/Core/Auth/Application.php b/lib/Horde/Core/Auth/Application.php index 17aef637d..7b8c06ca0 100644 --- a/lib/Horde/Core/Auth/Application.php +++ b/lib/Horde/Core/Auth/Application.php @@ -128,10 +128,12 @@ public function authenticate($userId, $credentials, $login = true) return false; } - try { - list($userId, $credentials) = $this->runHook(trim($userId), $credentials, 'preauthenticate', 'authenticate'); - } catch (Horde_Auth_Exception $e) { - return false; + if ($login) { + try { + list($userId, $credentials) = $this->runHook(trim($userId), $credentials, 'preauthenticate', 'authenticate'); + } catch (Horde_Auth_Exception $e) { + return false; + } } if ($this->_base) { @@ -141,7 +143,9 @@ public function authenticate($userId, $credentials, $login = true) } elseif (!parent::authenticate($userId, $credentials, $login)) { return false; } - + if (!$login) { + return true; + } /* Remember the user's mode choice, if applicable. */ if (!empty($credentials['mode'])) { $this->_view = $credentials['mode'];