diff --git a/public_html/deployment/classes/userauth.interface.php b/public_html/deployment/classes/userauth.interface.php index 83a4a3acb9c1e5dab5938aa4ea8a39b66a05a19c..3bd5c8372f6e6e2ad1e560629ab5f13c7e170826 100644 --- a/public_html/deployment/classes/userauth.interface.php +++ b/public_html/deployment/classes/userauth.interface.php @@ -1,14 +1,23 @@ <?php /** * interface for user authentication + * * @author axel.hahn@iml.unibe.ch + * + * Axel <axel.hahn@unibe.ch> + * 2024-08-29 Axel php8 only; added variable types; use short array syntax */ -interface iUserAuth { +interface iUserAuth +{ /** - * verify if a given user and password combination is correct + * Verify if a given user and password combination is correct + * + * @param string $sUser username + * @param string $sPassword password + * @return boolean */ - public function authenticate($sUser, $sPassword); - + public function authenticate(string $sUser, string $sPassword): bool; + } \ No newline at end of file diff --git a/public_html/deployment/classes/userauth.ldap.class.php b/public_html/deployment/classes/userauth.ldap.class.php index 07c440ad5dcdba27fd6b7fe1548f018b78da33f2..a8e5bc1cc88d1e0b11b0db02df591249b3debdb4 100644 --- a/public_html/deployment/classes/userauth.ldap.class.php +++ b/public_html/deployment/classes/userauth.ldap.class.php @@ -8,42 +8,58 @@ require_once("ldap.class.php"); * implements userauth interface * * @author hahn + * + * Axel <axel.hahn@unibe.ch> + * 2024-08-29 Axel php8 only; added variable types */ -class userauthLdap implements iUserAuth { +class userauthLdap implements iUserAuth +{ /** * object for ldap actions * @var object */ - private $_oLdap=false; - + private object $_oLdap; + // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public function __construct() { + + /** + * Constructor + */ + public function __construct() + { global $aConfig; - $this->_oLdap=new imlldap($aConfig['auth']['ldap']); - + $this->_oLdap = new imlldap($aConfig['auth']['ldap']); + // first test of ldap connection // $this->_oLdap->debugOn(); $this->_oLdap->connect(); - return true; } - - public function __destruct() { + + /** + * Destructor + * Close ldap connection + */ + public function __destruct() + { $this->_oLdap->close(); } - + // ---------------------------------------------------------------------- // implementation // ---------------------------------------------------------------------- + /** - * verify if a given user and password combination is correct - * @param string $sUser username - * @param password $sPassword password + * Verify if a given user and password combination is correct + * + * @param string $sUser username + * @param string $sPassword password * @return boolean */ - public function authenticate($sUser, $sPassword){ + public function authenticate(string $sUser, string $sPassword): bool + { return $this->_oLdap->verifyPassword($sUser, $sPassword); }