parent
8797d3e095
commit
ed53ab6c9d
|
@ -18,7 +18,7 @@ class LdapUserBackend implements UserBackend
|
|||
|
||||
public function hasUsername($username)
|
||||
{
|
||||
if (! $username) {
|
||||
if (!$username) {
|
||||
return false;
|
||||
}
|
||||
return $this->connection->fetchOne(
|
||||
|
@ -43,13 +43,15 @@ class LdapUserBackend implements UserBackend
|
|||
if (empty($username) || empty($password)) {
|
||||
return false;
|
||||
}
|
||||
if (! $this->connection->testCredentials(
|
||||
|
||||
if (!$this->connection->testCredentials(
|
||||
$this->connection->fetchDN($this->selectUsername($username)),
|
||||
$password
|
||||
)) {
|
||||
) ) {
|
||||
return false;
|
||||
}
|
||||
$user = new User($username);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace Icinga\Authentication;
|
||||
|
||||
|
||||
class Credentials
|
||||
{
|
||||
protected $username;
|
||||
|
|
|
@ -7,15 +7,18 @@ namespace Icinga\Authentication;
|
|||
use Icinga\Application\Logger as Logger;
|
||||
|
||||
/**
|
||||
* Standard PHP Session handling
|
||||
* You have to call read() first in order to start the session. If
|
||||
* no parameter is given to read, the session is closed immediately
|
||||
* after reading the persisted variables, in order to avoid concurrent
|
||||
* requests to be blocked. Otherwise, you can call write() (again with
|
||||
* no parameter in order to auto-close it) to persist all values previously
|
||||
* set with the set() method
|
||||
*
|
||||
**/
|
||||
* Class PhpSession
|
||||
*
|
||||
* Standard PHP Session handling
|
||||
* You have to call read() first in order to start the session. If
|
||||
* no parameter is given to read, the session is closed immediately
|
||||
* after reading the persisted variables, in order to avoid concurrent
|
||||
* requests to be blocked. Otherwise, you can call write() (again with
|
||||
* no parameter in order to auto-close it) to persist all values previously
|
||||
* set with the set() method
|
||||
*
|
||||
* @package Icinga\Authentication
|
||||
*/
|
||||
class PhpSession extends Session
|
||||
{
|
||||
const SESSION_NAME = "Icinga2Web";
|
||||
|
@ -32,7 +35,6 @@ class PhpSession extends Session
|
|||
'hash_bits_per_character' => 5,
|
||||
);
|
||||
|
||||
|
||||
public function __construct(array $options = null)
|
||||
{
|
||||
if ($options !== null) {
|
||||
|
@ -114,9 +116,11 @@ class PhpSession extends Session
|
|||
$_SESSION[$key] = $value;
|
||||
}
|
||||
if ($keepOpen) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
$this->close();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function close()
|
||||
|
|
|
@ -7,8 +7,7 @@ namespace Icinga\Authentication;
|
|||
abstract class Session
|
||||
{
|
||||
private $sessionValues = array();
|
||||
|
||||
|
||||
|
||||
abstract public function open();
|
||||
abstract public function read($keepOpen = false);
|
||||
abstract public function write($keepOpen = false);
|
||||
|
|
|
@ -30,12 +30,21 @@ class User
|
|||
private $permissions = array();
|
||||
private $groups = array();
|
||||
|
||||
public function __construct($username, $firstname, $lastname, $email)
|
||||
public function __construct($username, $firstname = null, $lastname = null, $email = null)
|
||||
{
|
||||
$this->setUsername($username);
|
||||
$this->setFirstname($firstname);
|
||||
$this->setLastname($lastname);
|
||||
$this->setEmail($email);
|
||||
|
||||
if ($firstname !== null) {
|
||||
$this->setFirstname($firstname);
|
||||
}
|
||||
|
||||
if ($lastname !== null) {
|
||||
$this->setLastname($lastname);
|
||||
}
|
||||
|
||||
if ($email !== null) {
|
||||
$this->setEmail($email);
|
||||
}
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
|
|
|
@ -6,7 +6,10 @@ require_once("../../library/Icinga/Protocol/Statusdat/Reader.php");
|
|||
require_once("../../library/Icinga/Exception/ConfigurationError.php");
|
||||
|
||||
use Icinga\Protocol\Statusdat\Reader as Reader;
|
||||
define("APPLICATION_PATH","./"); // TODO: test boostrap
|
||||
|
||||
if (!defined('APPLICATION_PATH')) {
|
||||
define("APPLICATION_PATH","./"); // TODO: test boostrap
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Test class for Reader
|
||||
|
|
Loading…
Reference in New Issue