Skip to content
Snippets Groups Projects
Commit 9a0cc4b1 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

user auth interface and ldap: php8 only; added variable types; use short array syntax

parent 3b477eda
No related branches found
No related tags found
1 merge request!66php8 only; added variable types; short array syntax; remove glyphicons
<?php <?php
/** /**
* interface for user authentication * interface for user authentication
*
* @author axel.hahn@iml.unibe.ch * @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
...@@ -8,42 +8,58 @@ require_once("ldap.class.php"); ...@@ -8,42 +8,58 @@ require_once("ldap.class.php");
* implements userauth interface * implements userauth interface
* *
* @author hahn * @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 * object for ldap actions
* @var object * @var object
*/ */
private $_oLdap=false; private object $_oLdap;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public function __construct() {
/**
* Constructor
*/
public function __construct()
{
global $aConfig; global $aConfig;
$this->_oLdap = new imlldap($aConfig['auth']['ldap']); $this->_oLdap = new imlldap($aConfig['auth']['ldap']);
// first test of ldap connection // first test of ldap connection
// $this->_oLdap->debugOn(); // $this->_oLdap->debugOn();
$this->_oLdap->connect(); $this->_oLdap->connect();
return true;
} }
public function __destruct() { /**
* Destructor
* Close ldap connection
*/
public function __destruct()
{
$this->_oLdap->close(); $this->_oLdap->close();
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// implementation // implementation
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** /**
* 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 $sUser username
* @param password $sPassword password * @param string $sPassword password
* @return boolean * @return boolean
*/ */
public function authenticate($sUser, $sPassword){ public function authenticate(string $sUser, string $sPassword): bool
{
return $this->_oLdap->verifyPassword($sUser, $sPassword); return $this->_oLdap->verifyPassword($sUser, $sPassword);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment