Navigation Menu

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

Commit

Permalink
Prefix cyphered passwords inside role parameters with a specific stri…
Browse files Browse the repository at this point in the history
…ng. listParameters() removes prefix by default, can either keep it ($preserveCypheredPasswords) or blur passwords ($blurCypheredPasswords) by replacing with __AJXP_VALUE_SET__ value.
  • Loading branch information
cdujeu committed Mar 27, 2015
1 parent 3b7d464 commit f8d767f
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions core/src/core/classes/class.AJXP_Role.php
Expand Up @@ -41,6 +41,8 @@ class AJXP_Role implements AjxpGroupPathProvider
protected $actions = array();
protected $autoApplies = array();

static $cypheredPassPrefix = '$pydio_password$';

public function __construct($id)
{
$this->roleId = $id;
Expand Down Expand Up @@ -146,12 +148,12 @@ public function clearAcls()
* Send all role informations as an associative array
* @return array
*/
public function getDataArray()
public function getDataArray($blurPasswords = false)
{
$roleData = array();
$roleData["ACL"] = $this->listAcls();
$roleData["ACTIONS"] = $this->listActionsStates();
$roleData["PARAMETERS"] = $this->listParameters();
$roleData["PARAMETERS"] = $this->listParameters(false, $blurPasswords);
$roleData["APPLIES"] = $this->listAutoApplies();
return $roleData;
}
Expand Down Expand Up @@ -204,28 +206,54 @@ public function filterParameterValue($pluginId, $parameterName, $repositoryId, $
if (isSet($this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName])) {
$v = $this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName];
if($v === AJXP_VALUE_CLEAR) return "";
else return $v;
else return $this->filterCypheredPasswordValue($v);
}
if (isSet($this->parameters[$repositoryId][$pluginId][$parameterName])) {
$v = $this->parameters[$repositoryId][$pluginId][$parameterName];
if($v === AJXP_VALUE_CLEAR) return "";
else return $v;
else return $this->filterCypheredPasswordValue($v);
}
return $parameterValue;
}

/**
* @param bool $preserveCypheredPasswords
* @param bool $blurCypheredPasswords
* @return array Associative array of parameters : array[REPO_ID][PLUGIN_ID][PARAMETER_NAME] = PARAMETER_VALUE
*/
public function listParameters()
public function listParameters($preserveCypheredPasswords = false, $blurCypheredPasswords = false)
{
return $this->parameters;
if($preserveCypheredPasswords) return $this->parameters;

$copy = $this->parameters;
foreach($copy as $repo => &$plugs){
foreach($plugs as $plugName => &$plugData){
foreach($plugData as $paramName => &$paramValue){
$testValue = $this->filterCypheredPasswordValue($paramValue);
if($testValue != $paramValue){
if($blurCypheredPasswords) $paramValue = "__AJXP_VALUE_SET__";
else $paramValue = $testValue;
}
}
}
}
return $copy;
}

public function listAutoApplies()
{
return $this->autoApplies;
}

/**
* @param String $value
* @return String
*/
private function filterCypheredPasswordValue($value){
if(is_string($value) && strpos($value, self::$cypheredPassPrefix) === 0) return str_replace(self::$cypheredPassPrefix, "", $value);
return $value;
}

/**
* @param string $pluginId
* @param string $actionName
Expand Down Expand Up @@ -302,7 +330,7 @@ public function override(AJXP_Role $role)
$newRole->setAcl($repoId, $rightString);
}

$newParams = $this->array_merge_recursive2($role->listParameters(), $this->listParameters());
$newParams = $this->array_merge_recursive2($role->listParameters(true), $this->listParameters(true));
foreach ($newParams as $repoId => $data) {
foreach ($data as $pluginId => $param) {
foreach ($param as $parameterName => $parameterValue) {
Expand Down

0 comments on commit f8d767f

Please sign in to comment.