Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ list: sork
type: application
homepage: https://www.horde.org/apps/passwd
authors:
-
name: Jan Schneider
- name: Jan Schneider
user: jan
email: jan@horde.org
active: true
role: lead
-
name: Michael Slusarz
- name: Michael Slusarz
user: slusarz
email: slusarz@horde.org
active: false
Expand Down Expand Up @@ -62,3 +60,4 @@ autoload:
psr-4:
Horde\Passwd\: /src
vendor: horde
keywords:
6 changes: 3 additions & 3 deletions lib/Application.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2002-2017 Horde LLC (http://www.horde.org/)
* Copyright 2002-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand All @@ -13,13 +13,13 @@
*/

if (!defined('PASSWD_BASE')) {
define('PASSWD_BASE', __DIR__. '/..');
define('PASSWD_BASE', __DIR__ . '/..');
}

if (!defined('HORDE_BASE')) {
/* If horde does not live directly under the app directory, the HORDE_BASE
* constant should be defined in config/horde.local.php. */
if (file_exists(PASSWD_BASE. '/config/horde.local.php')) {
if (file_exists(PASSWD_BASE . '/config/horde.local.php')) {
include PASSWD_BASE . '/config/horde.local.php';
} else {
define('HORDE_BASE', PASSWD_BASE . '/..');
Expand Down
53 changes: 32 additions & 21 deletions lib/Basic.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

use Horde\Util\Variables;
use Horde\Util\Util;

/**
* Copyright 2000-2017 Horde LLC (http://www.horde.org/)
* Copyright 2000-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -61,7 +62,12 @@ public function __construct(Variables|Horde_Variables $vars)
$this->_userid = $vars->get('userid', $this->_userid);
} else {
try {
$this->_userid = Horde::callHook('default_username', array(), 'passwd');
/**
* ARCHITECTURE VIOLATION: Using deprecated Horde::callHook()
* @deprecated Use $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook() instead
* @see Horde_Deprecated::callHook()
*/
$this->_userid = Horde::callHook('default_username', [], 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}
}
Expand All @@ -84,7 +90,7 @@ public function render()
public function status()
{
Horde::startBuffer();
$GLOBALS['notification']->notify(array('listeners' => array('status')));
$GLOBALS['notification']->notify(['listeners' => ['status']]);
return Horde::endBuffer();
}

Expand Down Expand Up @@ -121,15 +127,15 @@ private function _init()
}
}

$view = new Horde_View(array(
'templatePath' => PASSWD_TEMPLATES
));
$view = new Horde_View([
'templatePath' => PASSWD_TEMPLATES,
]);
$view->addHelper('FormTag');
$view->addHelper('Horde_Core_View_Helper_Help');
$view->addHelper('Horde_Core_View_Helper_Label');
$view->addHelper('Tag');

$view->formInput = Horde_Util::formInput();
$view->formInput = Util::formInput();
$view->url = $this->_vars->return_to ?: '';
$view->userid = $this->_userid ?: '';
$view->userChange = $conf['user']['change'];
Expand All @@ -150,14 +156,14 @@ private function _init()
$page_output->addScriptFile('stripe.js', 'horde');
$page_output->addScriptFile('passwd.js');

$page_output->addInlineJsVars(array(
'var Passwd' => array(
$page_output->addInlineJsVars([
'var Passwd' => [
'current_pass' => _("Please provide your current password"),
'new_pass' => _("Please provide a new password"),
'verify_pass' => _("Please verify your new password"),
'no_match' => _("Your passwords do not match"),
)
));
],
]);

$this->_output = $view->render('index');
}
Expand Down Expand Up @@ -203,7 +209,7 @@ private function _changePassword($backend_key)
$b_ptr = $this->_backends[$backend_key];

try {
Horde_Auth::checkPasswordPolicy($this->_vars->newpassword0, isset($b_ptr['policy']) ? $b_ptr['policy'] : array());
Horde_Auth::checkPasswordPolicy($this->_vars->newpassword0, $b_ptr['policy'] ?? []);
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
Expand All @@ -212,7 +218,7 @@ private function _changePassword($backend_key)
// Do some simple strength tests, if enabled in the config file.
if (!empty($conf['password']['strengthtests'])) {
try {
Horde_Auth::checkPasswordSimilarity($this->_vars->newpassword0, array($this->_userid, $this->_vars->oldpassword));
Horde_Auth::checkPasswordSimilarity($this->_vars->newpassword0, [$this->_userid, $this->_vars->oldpassword]);
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
Expand Down Expand Up @@ -241,15 +247,20 @@ private function _changePassword($backend_key)
$notification->push(sprintf(_("Password changed on %s."), $b_ptr['name']), 'horde.success');

try {
Horde::callHook('password_changed', array($this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0), 'passwd');
/**
* ARCHITECTURE VIOLATION: Using deprecated Horde::callHook()
* @deprecated Use $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook() instead
* @see Horde_Deprecated::callHook()
*/
Horde::callHook('password_changed', [$this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0], 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}

if (!empty($b_ptr['logout'])) {
$logout_url = $registry->getLogoutUrl(array(
$logout_url = $registry->getLogoutUrl([
'msg' => _("Your password has been succesfully changed. You need to re-login to the system with your new password."),
'reason' => Horde_Auth::REASON_MESSAGE
));
'reason' => Horde_Auth::REASON_MESSAGE,
]);
$registry->clearAuth();
$logout_url->redirect();
}
Expand Down Expand Up @@ -280,15 +291,15 @@ private function _isPreferredBackend($backend)
if (is_array($backend['preferred'])) {
foreach ($backend['preferred'] as $backend) {
if (
$backend == $_SERVER['SERVER_NAME'] ||
$backend == $_SERVER['HTTP_HOST']
$backend == $_SERVER['SERVER_NAME']
|| $backend == $_SERVER['HTTP_HOST']
) {
return true;
}
}
} elseif (
$backend['preferred'] == $_SERVER['SERVER_NAME'] ||
$backend['preferred'] == $_SERVER['HTTP_HOST']
$backend['preferred'] == $_SERVER['SERVER_NAME']
|| $backend['preferred'] == $_SERVER['HTTP_HOST']
) {
return true;
}
Expand Down
13 changes: 9 additions & 4 deletions lib/Driver.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2000-2017 Horde LLC (http://www.horde.org/)
* Copyright 2000-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -29,14 +29,14 @@ abstract class Passwd_Driver
*
* @var array
*/
protected $_params = array();
protected $_params = [];

/**
* Constructor.
*
* @param $params A hash containing connection parameters.
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
$this->_params = $params;
}
Expand Down Expand Up @@ -107,7 +107,12 @@ protected function _encryptPassword($plaintext)
public function changePassword($user, $oldpass, $newpass)
{
try {
$user = Horde::callHook('username', array($user, $this), 'passwd');
/**
* ARCHITECTURE VIOLATION: Using deprecated Horde::callHook()
* @deprecated Use $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook() instead
* @see Horde_Deprecated::callHook()
*/
$user = Horde::callHook('username', [$user, $this], 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Adsi.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2004-2017 Horde LLC (http://www.horde.org/)
* Copyright 2004-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down
10 changes: 5 additions & 5 deletions lib/Driver/Composite.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
* Copyright 2003-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -37,7 +37,7 @@ class Passwd_Driver_Composite extends Passwd_Driver
*
* @throws Passwd_Exception
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
if (!isset($params['drivers']) || !is_array($params['drivers'])) {
throw new Passwd_Exception(_("Required 'drivers' is misconfigured in Composite configuration."));
Expand All @@ -60,9 +60,9 @@ protected function _loadDrivers()
foreach ($this->_params['drivers'] as $key => $val) {
if (!isset($this->_drivers[$key])) {
try {
$res = $driver->create($key, array_merge($val, array(
'is_subdriver' => true
)));
$res = $driver->create($key, array_merge($val, [
'is_subdriver' => true,
]));
} catch (Passwd_Exception $e) {
throw new Passwd_Exception(sprintf(_("%s: unable to load sub driver: %s"), $key, $e->getMessage()));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Driver/Expect.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2000-2017 Horde LLC (http://www.horde.org/)
* Copyright 2000-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -36,9 +36,9 @@ protected function _changePassword($user, $oldpass, $newpass)
$log = Horde::getTempFile('passwd');

// Open expect script for writing.
$prog = 'LANG=C LC_ALL=C ' . $this->_params['program'] .
' -f ' . escapeshellarg($this->_params['script']) .
' -- ' . $this->_params['params'] . ' -log ' . escapeshellarg($log);
$prog = 'LANG=C LC_ALL=C ' . $this->_params['program']
. ' -f ' . escapeshellarg($this->_params['script'])
. ' -- ' . $this->_params['params'] . ' -log ' . escapeshellarg($log);

$exp = @popen($prog, 'w');
@fwrite($exp, $user . "\n");
Expand Down
16 changes: 8 additions & 8 deletions lib/Driver/Expectpecl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2006-2017 Horde LLC (http://www.horde.org/)
* Copyright 2006-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand All @@ -15,7 +15,7 @@
/**
* A PECL expect implementation of the Passwd system.
*
* Copyright 2006-2017 Horde LLC (http://www.horde.org/)
* Copyright 2006-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -45,13 +45,13 @@ class Passwd_Driver_Expectpecl extends Passwd_Driver
*/
protected function _ctl($expect, $error)
{
$result = expect_expectl($this->_stream, array(
array(
$result = expect_expectl($this->_stream, [
[
0 => $expect,
1 => 'ok',
2 => EXP_REGEXP
)
));
2 => EXP_REGEXP,
],
]);

switch ($result) {
case EXP_EOF:
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function _changePassword($user, $oldpass, $newpass)
}

// Set up parameters
foreach (array('logfile', 'loguser', 'timeout') as $val) {
foreach (['logfile', 'loguser', 'timeout'] as $val) {
if (isset($this->_params[$val])) {
ini_set('expect.' . $val, $this->_params[$val]);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Driver/Horde.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
* Copyright 2011-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -39,11 +39,11 @@ protected function _changePassword($user, $oldpass, $newpass)

/* Check the provided old password. */
try {
if ($auth->authenticate($user, array('password' => $oldpass, false))) {
if ($auth->authenticate($user, ['password' => $oldpass, false])) {
/* Actually modify the password. */
$auth->updateUser($user, $user, array(
'password' => $newpass
));
$auth->updateUser($user, $user, [
'password' => $newpass,
]);
} else {
throw new Passwd_Exception(_("Incorrect old password."));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Driver/Http.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright 2000-2017 Horde LLC (http://www.horde.org/)
* Copyright 2000-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
Expand Down Expand Up @@ -30,12 +30,12 @@ protected function _changePassword($user, $oldpass, $newpass)
{
// Add the required fields that most web-based forms would use.
// Then add any fields that were passed in _params['fields'].
$post_data = array_merge(array(
$post_data = array_merge([
$this->_params['username'] => $user,
$this->_params['oldPasswd'] => $oldpass,
$this->_params['passwd1'] => $newpass,
$this->_params['passwd2'] => $newpass
), $this->_params['fields']);
$this->_params['passwd2'] => $newpass,
], $this->_params['fields']);

// Send the request
try {
Expand Down
Loading
Loading