Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated LDAP Integration #738

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions doc/user-api/sections/user.text.tex
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,52 @@ \subsection*{\textit{enableUser}}
}
\end{verbatim}
}
\subsection*{\textit{disableLDAP}}
Disables LDAP authentication for an account.
{
\color{blue}
\begin{verbatim}
{
"section": "user",
"request": "disableLDAP",
"userId": 3,
"accessKey": "mykey"
}
\end{verbatim}
}
{
\color{OliveGreen}
\begin{verbatim}
{
"section": "user",
"request": "disableLDAP",
"response": "OK"
}
\end{verbatim}
}
\subsection*{\textit{enableLDAP}}
Enables LDAP authentication for an account.
{
\color{blue}
\begin{verbatim}
{
"section": "user",
"request": "enableLDAP",
"userId": 3,
"accessKey": "mykey"
}
\end{verbatim}
}
{
\color{OliveGreen}
\begin{verbatim}
{
"section": "user",
"request": "enableLDAP",
"response": "OK"
}
\end{verbatim}
}
\subsection*{\textit{setUserPassword}}
Set a new password for the user. This will not affect open sessions, only new logins.
{
Expand Down
121 changes: 81 additions & 40 deletions src/dba/models/User.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class User extends AbstractModel {
private $passwordHash;
private $passwordSalt;
private $isValid;
private $isLDAP;
private $isComputedPassword;
private $lastLoginDate;
private $registeredSince;
Expand All @@ -19,14 +20,44 @@ class User extends AbstractModel {
private $otp2;
private $otp3;
private $otp4;

function __construct($userId, $username, $email, $passwordHash, $passwordSalt, $isValid, $isComputedPassword, $lastLoginDate, $registeredSince, $sessionLifetime, $rightGroupId, $yubikey, $otp1, $otp2, $otp3, $otp4) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand what the idea is behind having two constructors, this would break the way how the Models are generated.
In src/dba/models/generator.php there are all models defined in arrays, which would be the way to go to add another column for a table. After this, just all new User( calls would need to be searched to adjust the arguments.


function __construct() {
$arguments = func_get_args();
$numberOfArguments = func_num_args();

if (method_exists($this, $function = '__construct'.$numberOfArguments)) {
call_user_func_array(array($this, $function), $arguments);
}
}

function __construct16($userId, $username, $email, $passwordHash, $passwordSalt, $isValid, $isComputedPassword, $lastLoginDate, $registeredSince, $sessionLifetime, $rightGroupId, $yubikey, $otp1, $otp2, $otp3, $otp4) {
$this->userId = $userId;
$this->username = $username;
$this->email = $email;
$this->passwordHash = $passwordHash;
$this->passwordSalt = $passwordSalt;
$this->isValid = $isValid;
$this->isLDAP = 0;
$this->isComputedPassword = $isComputedPassword;
$this->lastLoginDate = $lastLoginDate;
$this->registeredSince = $registeredSince;
$this->sessionLifetime = $sessionLifetime;
$this->rightGroupId = $rightGroupId;
$this->yubikey = $yubikey;
$this->otp1 = $otp1;
$this->otp2 = $otp2;
$this->otp3 = $otp3;
$this->otp4 = $otp4;
}

function __construct17($userId, $username, $email, $passwordHash, $passwordSalt, $isValid, $isLDAP, $isComputedPassword, $lastLoginDate, $registeredSince, $sessionLifetime, $rightGroupId, $yubikey, $otp1, $otp2, $otp3, $otp4) {
$this->userId = $userId;
$this->username = $username;
$this->email = $email;
$this->passwordHash = $passwordHash;
$this->passwordSalt = $passwordSalt;
$this->isValid = $isValid;
$this->isLDAP = $isLDAP;
$this->isComputedPassword = $isComputedPassword;
$this->lastLoginDate = $lastLoginDate;
$this->registeredSince = $registeredSince;
Expand All @@ -38,7 +69,7 @@ function __construct($userId, $username, $email, $passwordHash, $passwordSalt, $
$this->otp3 = $otp3;
$this->otp4 = $otp4;
}

function getKeyValueDict() {
$dict = array();
$dict['userId'] = $this->userId;
Expand All @@ -47,6 +78,7 @@ function getKeyValueDict() {
$dict['passwordHash'] = $this->passwordHash;
$dict['passwordSalt'] = $this->passwordSalt;
$dict['isValid'] = $this->isValid;
$dict['isLDAP'] = $this->isLDAP;
$dict['isComputedPassword'] = $this->isComputedPassword;
$dict['lastLoginDate'] = $this->lastLoginDate;
$dict['registeredSince'] = $this->registeredSince;
Expand All @@ -57,160 +89,169 @@ function getKeyValueDict() {
$dict['otp2'] = $this->otp2;
$dict['otp3'] = $this->otp3;
$dict['otp4'] = $this->otp4;

return $dict;
}

function getPrimaryKey() {
return "userId";
}

function getPrimaryKeyValue() {
return $this->userId;
}

function getId() {
return $this->userId;
}

function setId($id) {
$this->userId = $id;
}

/**
* Used to serialize the data contained in the model
* @return array
*/
public function expose() {
return get_object_vars($this);
}

function getUsername() {
return $this->username;
}

function setUsername($username) {
$this->username = $username;
}

function getEmail() {
return $this->email;
}

function setEmail($email) {
$this->email = $email;
}

function getPasswordHash() {
return $this->passwordHash;
}

function setPasswordHash($passwordHash) {
$this->passwordHash = $passwordHash;
}

function getPasswordSalt() {
return $this->passwordSalt;
}

function setPasswordSalt($passwordSalt) {
$this->passwordSalt = $passwordSalt;
}

function getIsValid() {
return $this->isValid;
}

function setIsValid($isValid) {
$this->isValid = $isValid;
}


function getIsLDAP() {
return $this->isLDAP;
}

function setIsLDAP($isLDAP) {
$this->isLDAP = $isLDAP;
}

function getIsComputedPassword() {
return $this->isComputedPassword;
}

function setIsComputedPassword($isComputedPassword) {
$this->isComputedPassword = $isComputedPassword;
}

function getLastLoginDate() {
return $this->lastLoginDate;
}

function setLastLoginDate($lastLoginDate) {
$this->lastLoginDate = $lastLoginDate;
}

function getRegisteredSince() {
return $this->registeredSince;
}

function setRegisteredSince($registeredSince) {
$this->registeredSince = $registeredSince;
}

function getSessionLifetime() {
return $this->sessionLifetime;
}

function setSessionLifetime($sessionLifetime) {
$this->sessionLifetime = $sessionLifetime;
}

function getRightGroupId() {
return $this->rightGroupId;
}

function setRightGroupId($rightGroupId) {
$this->rightGroupId = $rightGroupId;
}

function getYubikey() {
return $this->yubikey;
}

function setYubikey($yubikey) {
$this->yubikey = $yubikey;
}

function getOtp1() {
return $this->otp1;
}

function setOtp1($otp1) {
$this->otp1 = $otp1;
}

function getOtp2() {
return $this->otp2;
}

function setOtp2($otp2) {
$this->otp2 = $otp2;
}

function getOtp3() {
return $this->otp3;
}

function setOtp3($otp3) {
$this->otp3 = $otp3;
}

function getOtp4() {
return $this->otp4;
}

function setOtp4($otp4) {
$this->otp4 = $otp4;
}

const USER_ID = "userId";
const USERNAME = "username";
const EMAIL = "email";
const PASSWORD_HASH = "passwordHash";
const PASSWORD_SALT = "passwordSalt";
const IS_VALID = "isValid";
const IS_LDAP = "isLDAP";
const IS_COMPUTED_PASSWORD = "isComputedPassword";
const LAST_LOGIN_DATE = "lastLoginDate";
const REGISTERED_SINCE = "registeredSince";
Expand Down
4 changes: 2 additions & 2 deletions src/dba/models/UserFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getCacheValidTime() {
* @return User
*/
function getNullObject() {
$o = new User(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
$o = new User(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
return $o;
}

Expand All @@ -33,7 +33,7 @@ function getNullObject() {
* @return User
*/
function createObjectFromDict($pk, $dict) {
$o = new User($dict['userId'], $dict['username'], $dict['email'], $dict['passwordHash'], $dict['passwordSalt'], $dict['isValid'], $dict['isComputedPassword'], $dict['lastLoginDate'], $dict['registeredSince'], $dict['sessionLifetime'], $dict['rightGroupId'], $dict['yubikey'], $dict['otp1'], $dict['otp2'], $dict['otp3'], $dict['otp4']);
$o = new User($dict['userId'], $dict['username'], $dict['email'], $dict['passwordHash'], $dict['passwordSalt'], $dict['isValid'], $dict['isLDAP'], $dict['isComputedPassword'], $dict['lastLoginDate'], $dict['registeredSince'], $dict['sessionLifetime'], $dict['rightGroupId'], $dict['yubikey'], $dict['otp1'], $dict['otp2'], $dict['otp3'], $dict['otp4']);
return $o;
}

Expand Down
Loading