From 109fb513378be6eb50d72b9c77a650e75243bc39 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 15 May 2016 12:16:51 +0200 Subject: [PATCH] (auth) make Local auth extendable --- .../mvc/app/library/OPNsense/Auth/Local.php | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php b/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php index d1d3e771c..c6d421427 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php +++ b/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php @@ -56,12 +56,11 @@ class Local implements IAuthConnector } /** - * authenticate user against local database (in config.xml) - * @param string $username username to authenticate - * @param string $password user password - * @return bool authentication status + * find user settings in local database + * @param string $username username to find + * @return SimpleXMLElement|null user settings (xml section) */ - public function authenticate($username, $password) + protected function getUser($username) { // search local user in database $configObj = Config::getInstance()->object(); @@ -73,7 +72,24 @@ class Local implements IAuthConnector break; } } + return $userObject; + } + /** + * authenticate user against local database (in config.xml) + * @param string|SimpleXMLElement $username username (or xml object) to authenticate + * @param string $password user password + * @return bool authentication status + */ + public function authenticate($username, $password) + { + if (is_a($username, 'SimpleXMLElement')) { + // user xml section provided + $userObject = $username; + } else { + // get xml section from config + $userObject = $this->getUser($username); + } if ($userObject != null) { if (isset($userObject->disabled)) { // disabled user