Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 608c2cd

Browse files
committed
Ability to set multiple locks on users, they will be stacked and applied one by one.
1 parent 3d75e96 commit 608c2cd

File tree

16 files changed

+81
-26
lines changed

16 files changed

+81
-26
lines changed

core/src/core/src/pydio/Core/Model/UserInterface.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ public function setLock($lockAction);
9595
/**
9696
* @throws \Exception
9797
*/
98-
public function removeLock();
98+
public function removeLock($lockAction);
99+
100+
/**
101+
* @param $lockAction
102+
* @return string|false
103+
*/
104+
public function hasLockByName($lockAction);
99105

100106
/**
101107
* @return string|false

core/src/core/src/pydio/Core/Services/AuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function logUser($user_id, $pwd, $bypass_pwd = false, $cookieLogin
125125
}
126126

127127

128-
if ($user->getLock() === "logout") {
128+
if ($user->hasLockByName("logout")) {
129129
Logger::warning(__CLASS__, "Login failed", array("user" => InputFilter::sanitize($user_id, InputFilter::SANITIZE_EMAILCHARS), "error" => "Locked user"));
130130
throw new LoginException(-1);
131131
}

core/src/plugins/access.ajxp_conf/src/UsersManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function usersActions(ServerRequestInterface $requestInterface, ResponseI
290290
$userMessage = new UserMessage("Successfully set lock on user ($lockType)");
291291
$responseInterface = $responseInterface->withBody(new SerializableResponseStream([$userMessage]));
292292
} else {
293-
$userObject->removeLock();
293+
$userObject->removeLock($lockType);
294294
$userMessage = new UserMessage("Successfully unlocked user");
295295
$responseInterface = $responseInterface->withBody(new SerializableResponseStream([$userMessage]));
296296
}

core/src/plugins/action.disclaimer/DisclaimerProvider.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function toggleDisclaimer(ServerRequestInterface &$request, ResponseInter
6565

6666
if ($httpVars["validate"] == "true") {
6767

68-
$u->removeLock();
68+
$u->removeLock("validate_disclaimer");
6969
$u->save("superuser");
7070
AuthService::updateUser($u);
7171
$repo = SessionRepositoryMiddleware::switchUserToRepository($u, $request);
@@ -116,7 +116,7 @@ public function loadDisclaimer(ServerRequestInterface &$request, ResponseInterfa
116116
*/
117117
public function updateSharedUser(ContextInterface $ctx, UserInterface $userObject){
118118
if($userObject->isHidden() && !$this->getContextualOption($ctx, "DISCLAIMER_ENABLE_SHARED")){
119-
$userObject->removeLock();
119+
$userObject->removeLock("validate_disclaimer");
120120
$userObject->getPersonalRole()->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", "yes", AJXP_REPO_SCOPE_SHARED);
121121
$userObject->save("superuser");
122122
}
@@ -131,6 +131,13 @@ public function updateSharedUser(ContextInterface $ctx, UserInterface $userObjec
131131
* @param UserInterface $userObject
132132
*/
133133
public function updateSharedUserLogin(ContextInterface $ctx, UserInterface $userObject){
134+
if(!$userObject->isHidden()){
135+
$param = $userObject->getPersonalRole()->filterParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", AJXP_REPO_SCOPE_ALL, "no");
136+
if($param === "no"){
137+
$userObject->setLock("validate_disclaimer");
138+
$userObject->save("superuser");
139+
}
140+
}
134141
if($userObject->isHidden() && $this->getContextualOption($ctx, "DISCLAIMER_ENABLE_SHARED")){
135142
$userObject->setLock("validate_disclaimer");
136143
$userObject->getPersonalRole()->setParameterValue("action.disclaimer", "DISCLAIMER_ACCEPTED", "no", AJXP_REPO_SCOPE_SHARED);

core/src/plugins/authfront.duosecurity/DuoSecurityFrontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function postVerificationCode(\Psr\Http\Message\ServerRequestInterface $r
114114
$verif = Duo::verifyResponse($iKey, $sKey, $appUnique, $sigResponse);
115115

116116
if ($verif != null && $verif == $u->getId()) {
117-
$u->removeLock();
117+
$u->removeLock("duo_show_iframe");
118118
$u->save("superuser");
119119
$u->recomputeMergedRole();
120120
AuthService::updateUser($u);

core/src/plugins/authfront.otp/OtpAuthFrontend.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ function tryToLogUser(ServerRequestInterface &$request, ResponseInterface &$resp
104104
$userid = InputFilter::sanitize($httpVars["userid"], InputFilter::SANITIZE_EMAILCHARS);
105105
$this->loadConfig(UsersService::getUserById($userid));
106106
// if there is no configuration for OTP, this means that this user don't have OTP
107-
if ((empty($this->googleEnabled) && empty($this->google) && empty($this->googleLast) && empty($this->yubikey1) && empty($this->yubikey2))) {
107+
if(empty($this->googleEnabled)){
108+
return false;
109+
}
110+
if (empty($this->google) && empty($this->googleLast) && empty($this->yubikey1) && empty($this->yubikey2)) {
108111
return false;
109112
}
110113

@@ -224,7 +227,7 @@ public function getConfigurationCode(ServerRequestInterface $requestInterface, R
224227
$otp = $requestInterface->getParsedBody()["otp"];
225228
if($this->checkGooglePass($uObject->getId(), $otp, $this->google, $this->googleLast)){
226229
$responseInterface = new JsonResponse(["RESULT" => "OK"]);
227-
$uObject->removeLock();
230+
$uObject->removeLock("otp_show_setup_screen");
228231
$uObject->save("superuser");
229232
}else{
230233
throw new PydioException($mess["authfront.otp.7"]);

core/src/plugins/core.auth/AbstractAuthDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
9090
}
9191
if (UsersService::checkPassword($userObject->getId(), $oldPass, false, $passSeed)) {
9292
UsersService::updatePassword($userObject->getId(), $newPass);
93-
if ($userObject->getLock() == "pass_change") {
94-
$userObject->removeLock();
93+
if ($userObject->hasLockByName("pass_change")) {
94+
$userObject->removeLock("pass_change");
9595
$userObject->save("superuser");
9696
}
9797
} else {

core/src/plugins/core.conf/AbstractUser.php

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,31 @@ public function setProfile($profile)
247247
*/
248248
public function setLock($lockAction)
249249
{
250-
//$this->rights["ajxp.lock"] = $lockAction;
251-
$this->personalRole->setParameterValue('core.conf', 'USER_LOCK_ACTION', $lockAction);
250+
$sLock = $this->getLock();
251+
$currentLocks = !empty($sLock) ? explode(",", $sLock) : [] ;
252+
if(!in_array($lockAction, $currentLocks)){
253+
array_unshift($currentLocks, $lockAction);
254+
}
255+
$locks = implode(",", $currentLocks);
256+
$this->personalRole->setParameterValue('core.conf', 'USER_LOCK_ACTION', $locks);
252257
$this->recomputeMergedRole();
253258
}
254259

255-
public function removeLock()
260+
/**
261+
* @param $lockAction
262+
* @throws \Exception
263+
*/
264+
public function removeLock($lockAction)
256265
{
257-
if(isSet($this->rights['ajxp.lock'])){
258-
$this->rights["ajxp.lock"] = false;
266+
$sLock = $this->getLock();
267+
$currentLocks = !empty($sLock) ? explode(",", $sLock) : [] ;
268+
$pos = array_search($lockAction, $currentLocks);
269+
if($pos !== false){
270+
unset($currentLocks[$pos]);
259271
}
260-
$this->personalRole->setParameterValue('core.conf', 'USER_LOCK_ACTION', AJXP_VALUE_CLEAR);
272+
$this->rights["ajxp.lock"] = !count($currentLocks) ? false: implode(",", $currentLocks);
273+
$newValue = !count($currentLocks) ? AJXP_VALUE_CLEAR : implode(",", $currentLocks);
274+
$this->personalRole->setParameterValue('core.conf', 'USER_LOCK_ACTION', $newValue);
261275
$this->recomputeMergedRole();
262276
}
263277

@@ -266,13 +280,24 @@ public function removeLock()
266280
*/
267281
public function getLock()
268282
{
269-
if(AJXP_SERVER_DEBUG && $this->isAdmin() && $this->getGroupPath() == "/") return false;
283+
if(AJXP_SERVER_DEBUG && $this->isAdmin() && $this->getGroupPath() === "/") return false;
270284
if (!empty($this->rights["ajxp.lock"])) {
271285
return $this->rights["ajxp.lock"];
272286
}
273287
return $this->mergedRole->filterParameterValue('core.conf', 'USER_LOCK_ACTION', AJXP_REPO_SCOPE_ALL, false);
274288
}
275289

290+
/**
291+
* @param $lockAction
292+
* @return string|false
293+
*/
294+
public function hasLockByName($lockAction){
295+
$sLock = $this->getLock();
296+
$currentLocks = !empty($sLock) ? explode(",", $sLock) : [] ;
297+
return array_search($lockAction, $currentLocks) !== false;
298+
}
299+
300+
276301
/**
277302
* @return bool
278303
*/

core/src/plugins/editor.ajxp_role/class.RoleEditor.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,11 @@ Class.create("RoleEditor", AbstractEditor, {
364364
});
365365
modal.currentLightBoxModal.setStyle({display:'block'});
366366
}.bind(this));
367-
var locked = this.roleData.USER.LOCK ? true : false;
368-
var b1 = new Element("span", {className:'m-2'}).update((locked?MessageHash["ajxp_role_editor.27"]:MessageHash["ajxp_role_editor.26"]));
367+
var locked = this.roleData.USER.LOCK || "";
368+
var uLockedOut = locked.indexOf('logout') > 1;
369+
var uLockedPass = locked.indexOf('pass_change') > 1;
370+
371+
var b1 = new Element("span", {className:'m-2'}).update((uLockedOut ?MessageHash["ajxp_role_editor.27"]:MessageHash["ajxp_role_editor.26"]));
369372
buttonPane.insert(b1);
370373
var userId = this.roleId.replace("AJXP_USR_/", "");
371374
b1.observe("click", function(){
@@ -374,16 +377,16 @@ Class.create("RoleEditor", AbstractEditor, {
374377
get_action:"edit",
375378
sub_action:"user_set_lock",
376379
user_id : userId,
377-
lock : (locked?"false":"true")
380+
lock_type:"logout",
381+
lock : (uLockedOut?"false":"true")
378382
});
379-
if(!locked) conn.addParameter("lock_type", "logout");
380383
conn.onComplete = function(transport){
381-
locked = !locked;
382-
b1.update((locked?MessageHash["ajxp_role_editor.27"]:MessageHash["ajxp_role_editor.26"]));
384+
uLockedOut = !uLockedOut;
385+
b1.update((uLockedOut?MessageHash["ajxp_role_editor.27"]:MessageHash["ajxp_role_editor.26"]));
383386
}.bind(this);
384387
conn.sendAsync();
385388
}.bind(this) );
386-
var b2 = new Element("span", {className:'m-2'}).update(MessageHash["ajxp_role_editor.28"]);
389+
var b2 = new Element("span", {className:'m-2'}).update(uLockedPass ? MessageHash["ajxp_role_editor.28b"]: MessageHash["ajxp_role_editor.28"]);
387390
buttonPane.insert(b2);
388391
var userId = this.roleId.replace("AJXP_USR_/", "");
389392
b2.observe("click", function(){
@@ -392,9 +395,13 @@ Class.create("RoleEditor", AbstractEditor, {
392395
get_action:"edit",
393396
sub_action:"user_set_lock",
394397
user_id : userId,
395-
lock : "true",
398+
lock : uLockedPass ? "false" : "true",
396399
lock_type : "pass_change"
397400
});
401+
conn.onComplete = function(transport){
402+
uLockedPass = !uLockedPass;
403+
b2.update((uLockedPass?MessageHash["ajxp_role_editor.28b"]:MessageHash["ajxp_role_editor.28"]));
404+
}.bind(this);
398405
conn.sendAsync();
399406
});
400407

core/src/plugins/editor.ajxp_role/i18n/de.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"26" => "Benutzer sperren",
5959
"27" => "Benutzer aktivieren",
6060
"28" => "Passwortänderung erzwingen",
61+
"28b"=> "Cancel password change",
6162
"29" => "Geben Sie ein neues Passwort für den Benutzer ein",
6263
"30" => "Wiederholen",
6364
"31" => "Rollen-ID",

core/src/plugins/editor.ajxp_role/i18n/en.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"26" => "Lock out user",
5353
"27" => "Reactivate user",
5454
"28" => "Force password change",
55+
"28b"=> "Cancel password change",
5556
"29" => "Enter new password for this user",
5657
"30" => "Confirm",
5758
"31" => "Role ID",

core/src/plugins/editor.ajxp_role/i18n/fr.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"26" => "Exclure l'utilisateur",
5353
"27" => "Réactiver l'utilisateur",
5454
"28" => "Forcer une mise à jour du mot de passe",
55+
"28b"=> "Annuler la mise à jour forcée du mot de passe",
5556
"29" => "Entrez le nouveau mot de passe pour cet utilisateur",
5657
"30" => "Confirmez",
5758
"31" => "ID rôle",

core/src/plugins/editor.ajxp_role/i18n/it.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"26" => "Blocca Utente",
5353
"27" => "Riattiva Utente",
5454
"28" => "Forza cambio",
55+
"28b"=> "Cancel password change",
5556
"29" => "Inserisci la nuova password per questo utente",
5657
"30" => "Conferma",
5758
"31" => "ID Ruolo",

core/src/plugins/editor.ajxp_role/i18n/pt.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"26" => "Bloquear Utilizador",
5353
"27" => "Reactivar utilizador",
5454
"28" => "Forçar Mudança de Palavra-Chave",
55+
"28b"=> "Cancel password change",
5556
"29" => "Introduza uma nova Palavra-Chave para este utilizador",
5657
"30" => "Confirmar",
5758
"31" => "ID de Papel",

core/src/plugins/editor.ajxp_role/i18n/ru.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"26" => "Блокировка пользователя",
5353
"27" => "Переактивировать пользователя",
5454
"28" => "Принудительная смена пароля",
55+
"28b"=> "Cancel password change",
5556
"29" => "Введите новый пароль для этого пользователя",
5657
"30" => "Подтверждение",
5758
"31" => "ID роли",

core/src/plugins/gui.ajax/res/js/es6/Pydio.es6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ class Pydio extends Observable{
178178
if(!repositoryObject){
179179
if(this.user.lock){
180180
this.Controller.loadActionsFromRegistry(this.getXmlRegistry());
181+
let lock = this.user.lock.split(",").shift();
181182
window.setTimeout(function(){
182-
this.Controller.fireAction(this.user.lock);
183+
this.Controller.fireAction(lock);
183184
}.bind(this), 50);
184185
return;
185186
}

0 commit comments

Comments
 (0)