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

Handle password expiry in user_ldap #1023

Merged
merged 8 commits into from
Apr 24, 2017
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
3 changes: 2 additions & 1 deletion apps/user_ldap/ajax/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager());
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager());

$access = new \OCA\User_LDAP\Access($con, $ldapWrapper, $userManager, new \OCA\User_LDAP\Helper(
\OC::$server->getConfig()
Expand Down
19 changes: 16 additions & 3 deletions apps/user_ldap/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\User_LDAP\LDAP();
$ocConfig = \OC::$server->getConfig();
$notificationManager = \OC::$server->getNotificationManager();
$notificationManager->registerNotifier(function() {
return new \OCA\User_LDAP\Notification\Notifier(
\OC::$server->getL10NFactory()
);
}, function() {
$l = \OC::$server->getL10N('user_ldap');
return [
'id' => 'user_ldap',
'name' => $l->t('LDAP user and group backend'),
];
});
if(count($configPrefixes) === 1) {
$dbc = \OC::$server->getDatabaseConnection();
$userManager = new OCA\User_LDAP\User\Manager($ocConfig,
Expand All @@ -39,18 +51,19 @@
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc,
\OC::$server->getUserManager()
\OC::$server->getUserManager(),
$notificationManager
);
$connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper);

$ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
$ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
$userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig);
$userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig, $notificationManager);
$groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
} else if(count($configPrefixes) > 1) {
$userBackend = new OCA\User_LDAP\User_Proxy(
$configPrefixes, $ldapWrapper, $ocConfig
$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
);
$groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
}
Expand Down
3 changes: 2 additions & 1 deletion apps/user_ldap/appinfo/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
$uBackend = new User_Proxy(
$helper->getServerConfigurationPrefixes(true),
new LDAP(),
$ocConfig
$ocConfig,
\OC::$server->getNotificationManager()
);
$deletedUsersIndex = new DeletedUsersIndex(
$ocConfig, $dbConnection, $userMapping
Expand Down
10 changes: 10 additions & 0 deletions apps/user_ldap/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@
['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
]
]);

$application = new OCA\User_LDAP\AppInfo\Application();
$application->registerRoutes($this, [
'routes' => [
['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'],
['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'],
['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'],
['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'],
]
]);
20 changes: 20 additions & 0 deletions apps/user_ldap/css/renewPassword.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#personal-show + label {
left: 222px !important;
margin-top: 3px !important;
}

#renewpassword .strengthify-wrapper {
left: 10px;
margin-top: 65px;
position: absolute;
width: 219px;
}

#cancel-container p.info {
margin-top: 10px;
text-align: center;
}

#renewpassword .title {
background-color: transparent;
}
50 changes: 50 additions & 0 deletions apps/user_ldap/js/renewPassword.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
*
* @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de)
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

OCA = OCA || {};
OCA.LDAP = _.extend(OC.LDAP || {}, {
onRenewPassword: function () {
$('#submit')
.removeClass('icon-confirm-white')
.addClass('icon-loading-small')
.attr('value', t('core', 'Renewing …'));
return true;
},
});

$(document).ready(function() {
$('form[name=renewpassword]').submit(OCA.LDAP.onRenewPassword);

if($('#newPassword').length) {
$('#newPassword').showPassword().keyup();
}
$('#newPassword').strengthify({
zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
titles: [
t('core', 'Very weak password'),
t('core', 'Weak password'),
t('core', 'So-so password'),
t('core', 'Good password'),
t('core', 'Strong password')
],
drawTitles: true,
});
});
15 changes: 14 additions & 1 deletion apps/user_ldap/js/wizard/wizardTabAdvanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ OCA = OCA || {};
$element: $('#ldap_turn_on_pwd_change'),
setMethod: 'setPasswordChangeEnabled'
},
ldap_default_ppolicy_dn: {
$element: $('#ldap_default_ppolicy_dn'),
setMethod: 'setDefaultPPolicyDN'
},

//Special Attributes
ldap_quota_attr: {
Expand Down Expand Up @@ -292,7 +296,7 @@ OCA = OCA || {};
setPagingSize: function(size) {
this.setElementValue(this.managedItems.ldap_paging_size.$element, size);
},

/**
* sets whether the password changes per user should be enabled
*
Expand All @@ -304,6 +308,15 @@ OCA = OCA || {};
);
},

/**
* sets the default ppolicy attribute
*
* @param {string} attribute
*/
setDefaultPPolicyDN: function(attribute) {
this.setElementValue(this.managedItems.ldap_default_ppolicy_dn.$element, attribute);
},

/**
* sets the email attribute
*
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ private function countEntriesInSearchResults($searchResults) {
* @param bool $skipHandling
* @return array with the search result
*/
private function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
if($limit <= 0) {
//otherwise search will fail
$limit = null;
Expand Down
52 changes: 52 additions & 0 deletions apps/user_ldap/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
*
* @author Roger Szabo <roger.szabo@web.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\User_LDAP\AppInfo;

use OCA\User_LDAP\Controller\RenewPasswordController;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;

class Application extends App {
public function __construct () {
parent::__construct('user_ldap');
$container = $this->getContainer();

/**
* Controller
*/
$container->registerService('RenewPasswordController', function(IAppContainer $c) {
/** @var \OC\Server $server */
$server = $c->query('ServerContainer');

return new RenewPasswordController(
$c->getAppName(),
$server->getRequest(),
$c->query('UserManager'),
$server->getConfig(),
$c->query('OCP\IL10N'),
$server->getURLGenerator()
);
});
}
}
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Command/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$limit = null;
}
} else {
$proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
$proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig, \OC::$server->getNotificationManager());
$getMethod = 'getDisplayNames';
$printID = true;
}
Expand Down
3 changes: 3 additions & 0 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Configuration {
'ldapPagingSize' => null,
'turnOnPasswordChange' => false,
'ldapDynamicGroupMemberURL' => null,
'ldapDefaultPPolicyDN' => null,
);

/**
Expand Down Expand Up @@ -457,6 +458,7 @@ public function getDefaults() {
'ldap_turn_on_pwd_change' => 0,
'ldap_experienced_admin' => 0,
'ldap_dynamic_group_member_url' => '',
'ldap_default_ppolicy_dn' => '',
);
}

Expand Down Expand Up @@ -514,6 +516,7 @@ public function getConfigTranslationArray() {
'ldap_turn_on_pwd_change' => 'turnOnPasswordChange',
'ldap_experienced_admin' => 'ldapExperiencedAdmin',
'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL',
'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN',
);
return $array;
}
Expand Down
Loading