mirror of
https://github.com/silentsakky/zarafa-webapp-passwd
synced 2026-07-31 20:41:28 +02:00
Compare commits
13 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e919be0553 | ||
|
|
8310d7fb12 | ||
|
|
fffa1ddbbb | ||
|
|
3bcef6e388 | ||
|
|
a9549464e9 | ||
|
|
3cafedcf3a | ||
|
|
dd305cca3b | ||
|
|
db34d7f872 | ||
|
|
2e39b60f5b | ||
|
|
a0b6a813fc | ||
|
|
f0756b10ce | ||
|
|
eefb5fbc96 | ||
|
|
bc3800e618 |
16 changed files with 218 additions and 127 deletions
|
|
@ -9,4 +9,10 @@
|
||||||
## 1.2 (20th May 2015)
|
## 1.2 (20th May 2015)
|
||||||
|
|
||||||
- Bug fixes for LDAP plugin
|
- Bug fixes for LDAP plugin
|
||||||
- Improved UI
|
- Improved UI
|
||||||
|
|
||||||
|
## 1.3 (6th July 2017)
|
||||||
|
|
||||||
|
- Add config to enable/disable strict password checking
|
||||||
|
- use encryptionstore to retrieve/store passwords
|
||||||
|
- move strict password checking to client side
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Zarafa Webapp Password Change Plugin
|
Zarafa Webapp Password Change Plugin
|
||||||
Copyright (C) 2013 Saket Patel silentsakky@gmail.com
|
Copyright (C) 2013 - 2017 Saket Patel <silentsakky@gmail.com>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
32
README.md
32
README.md
|
|
@ -7,32 +7,46 @@ This plugin is largely based on the Passwd plugin by Andreas Brodowski.
|
||||||
For his original work check this [link](https://community.zarafa.com/pg/plugins/project/157/developer/dw2412/passwd-plugin)
|
For his original work check this [link](https://community.zarafa.com/pg/plugins/project/157/developer/dw2412/passwd-plugin)
|
||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
1. If you want to use this plugin with production / debug version of webapp then please download package from [community](https://community.zarafa.com/pg/plugins/project/23147/developer/silentsakky/webapp-password-change)
|
1. If you want to use this plugin with production / debug version of webapp then please download package from [release page](https://github.com/silentsakky/zarafa-webapp-passwd/releases)
|
||||||
2. If you want to use this plugin with source copy of webapp then you can just download this whole project
|
2. If you want to use this plugin with source copy of webapp then you can just download this whole project
|
||||||
3. Extract contents of this plugin to <webapp_path>/plugins directory
|
3. Extract contents of this plugin to <webapp_path>/plugins directory, in Ubuntu 16 <webapp_path> refers to /usr/share/kopano-webapp
|
||||||
4. Give read permissions to apache for <webapp_path>/plugins/passwd directory
|
4. Give read permissions to apache for <webapp_path>/plugins/passwd directory
|
||||||
5. If you are using LDAP plugin then change PLUGIN_PASSWD_LDAP to true and also set proper values for PLUGIN_PASSWD_LDAP_BASEDN and PLUGIN_PASSWD_LDAP_URI configurations
|
5. If you are using LDAP plugin then change PLUGIN_PASSWD_LDAP to true and also set proper values for PLUGIN_PASSWD_LDAP_BASEDN and PLUGIN_PASSWD_LDAP_URI configurations
|
||||||
6. If you are using DB plugin then no need to change anything, default configurations should be fine
|
6. If you are using DB plugin then no need to change anything, default configurations should be fine
|
||||||
5. Restart apache, reload webapp after clearing cache
|
5. Restart apache, reload webapp after clearing cache
|
||||||
6. If you want to enable this plugin by default for all users then edit config.php file and change PLUGIN_PASSWD_USER_DEFAULT_ENABLE setting to true
|
6. If you want to enable this plugin by default for all users then edit config.php file and change PLUGIN_PASSWD_USER_DEFAULT_ENABLE setting to true
|
||||||
|
|
||||||
|
|
||||||
## How to enable
|
## How to enable
|
||||||
1. Go to settings section
|
1. Go to settings section
|
||||||
2. Go to Plugins tab
|
2. Go to Plugins tab
|
||||||
3. Enable password change plugin and reload webapp
|
3. Enable password change plugin and reload webapp
|
||||||
4. Go to Change Password tab of settings section
|
|
||||||
5. Provide current password and new password
|
|
||||||
6. Click on apply
|
|
||||||
|
|
||||||
## How to disable
|
## How to disable
|
||||||
1. Go to settings section
|
1. Go to settings section
|
||||||
2. Go to Plugins tab
|
2. Go to Plugins tab
|
||||||
3. Disable password change plugin and reload webapp
|
3. Disable password change plugin and reload webapp
|
||||||
|
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
1. Go to Change Password tab of settings section
|
||||||
|
2. Provide current password and new password
|
||||||
|
3. Click on apply
|
||||||
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
- Feedback/Bug Reports are welcome
|
- Feedback/Bug Reports are welcome
|
||||||
- If anyone is good at creating icons then please help me add a good icon to change password tab (credits will be given)
|
- thanks to h44z for adding password meter and icon for the plugin
|
||||||
|
|
||||||
## Todo
|
|
||||||
- Add password strength meter on client side, so user can create complex passwords
|
## Dependencies:
|
||||||
- Check on client side for empty fields
|
- php ldap extension is required if you are using LDAP plugin
|
||||||
|
- if you have ubuntu 16 then follow below steps (this should ideally work with all distros)
|
||||||
|
1) sudo apt-get install php-ldap
|
||||||
|
2) sudo phpenmod ldap
|
||||||
|
3) check if ldap extension is enabled using below command
|
||||||
|
php -i "(command-line 'phpinfo()')" | grep ldap
|
||||||
|
|
||||||
|
|
||||||
|
Initially releases of this plugin were maintained in [community](https://community.zarafa.com/pg/plugins/project/23147/developer/silentsakky/webapp-password-change), but now users can download latest builds from [github release page](https://github.com/silentsakky/zarafa-webapp-passwd/releases)
|
||||||
|
|
@ -233,5 +233,13 @@
|
||||||
<exclude name="**/LC_MESSAGES/*.po"/>
|
<exclude name="**/LC_MESSAGES/*.po"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
|
<!-- Create zip file for release (ant -Drelease=true) -->
|
||||||
|
<if>
|
||||||
|
<isset property="release" />
|
||||||
|
<then>
|
||||||
|
<zip destfile="${target-folder}/${plugin}.zip" update="true" basedir="${target-folder}/${plugin}" />
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -2,7 +2,10 @@
|
||||||
/** Enable the passwd plugin for all clients **/
|
/** Enable the passwd plugin for all clients **/
|
||||||
define('PLUGIN_PASSWD_USER_DEFAULT_ENABLE', false);
|
define('PLUGIN_PASSWD_USER_DEFAULT_ENABLE', false);
|
||||||
|
|
||||||
/** Define zarafa installtion uses LDAP **/
|
/** Enable the passwd plugin for all clients **/
|
||||||
|
define('PLUGIN_PASSWD_STRICT_CHECK_ENABLE', true);
|
||||||
|
|
||||||
|
/** Define passwd plugin installation uses LDAP **/
|
||||||
define('PLUGIN_PASSWD_LDAP', false);
|
define('PLUGIN_PASSWD_LDAP', false);
|
||||||
|
|
||||||
/** Base DN to access LDAP users **/
|
/** Base DN to access LDAP users **/
|
||||||
|
|
@ -23,4 +26,4 @@ define('PLUGIN_PASSWD_LDAP_BIND_PW', "");
|
||||||
/** Set to true if you login with username@tenantname **/
|
/** Set to true if you login with username@tenantname **/
|
||||||
define('PLUGIN_PASSWD_LOGIN_WITH_TENANT', false);
|
define('PLUGIN_PASSWD_LOGIN_WITH_TENANT', false);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -6,7 +6,7 @@ Ext.namespace('Zarafa.plugins.passwd');
|
||||||
* The copyright string holding the copyright notice for the Zarafa passwd Plugin.
|
* The copyright string holding the copyright notice for the Zarafa passwd Plugin.
|
||||||
*/
|
*/
|
||||||
Zarafa.plugins.passwd.ABOUT = ""
|
Zarafa.plugins.passwd.ABOUT = ""
|
||||||
+ "<p>Copyright (C) 2013 Saket Patel <silentsakky@gmail.com></p>"
|
+ "<p>Copyright (C) 2013 - 2017 Saket Patel <silentsakky@gmail.com></p>"
|
||||||
|
|
||||||
+ "<p>This program is free software: you can redistribute it and/or modify "
|
+ "<p>This program is free software: you can redistribute it and/or modify "
|
||||||
+ "it under the terms of the GNU Affero General Public License as "
|
+ "it under the terms of the GNU Affero General Public License as "
|
||||||
|
|
|
||||||
3
js/external/PasswordMeter.js
vendored
3
js/external/PasswordMeter.js
vendored
|
|
@ -62,7 +62,8 @@ Ext.ux.form.field.PasswordMeter = Ext.extend(Ext.form.TextField, {
|
||||||
|
|
||||||
|
|
||||||
var width = this.getEl().getWidth();
|
var width = this.getEl().getWidth();
|
||||||
this.strengthMeterID = newID = Ext.id();
|
var newID = Ext.id();
|
||||||
|
this.strengthMeterID = newID;
|
||||||
this.scoreBarID = Ext.id();
|
this.scoreBarID = Ext.id();
|
||||||
var objMeter = Ext.DomHelper.insertAfter(this.getEl(), {
|
var objMeter = Ext.DomHelper.insertAfter(this.getEl(), {
|
||||||
tag: "div",
|
tag: "div",
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,15 @@ Zarafa.plugins.passwd.settings.SettingsPasswdWidget = Ext.extend(Zarafa.settings
|
||||||
} else if(!this.passwdPanel.getForm().isValid()) {
|
} else if(!this.passwdPanel.getForm().isValid()) {
|
||||||
Ext.MessageBox.alert(dgettext("plugin_passwd", 'Error'), dgettext("plugin_passwd", 'One or more fields does contain errors.'));
|
Ext.MessageBox.alert(dgettext("plugin_passwd", 'Error'), dgettext("plugin_passwd", 'One or more fields does contain errors.'));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else if (container.getSettingsModel().get("zarafa/v1/plugins/passwd/enable_strict_check")) {
|
||||||
// do a quick score check:
|
// do a quick score check:
|
||||||
if(this.passwdPanel.new_password.getScore() < 70) {
|
if(this.passwdPanel.new_password.getScore() < 70) {
|
||||||
Ext.MessageBox.alert(dgettext("plugin_passwd", 'Error'), dgettext("plugin_passwd", 'Password is weak. Password should contain capital, non-capital letters and numbers. Password should have 8 to 20 characters.'));
|
Ext.MessageBox.alert(dgettext("plugin_passwd", 'Error'), dgettext("plugin_passwd", 'Password is weak. Password should contain capital, non-capital letters and numbers. Password should have 8 to 20 characters.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
BIN
language/hu_HU.UTF-8/LC_MESSAGES/plugin_passwd.mo
Normal file
BIN
language/hu_HU.UTF-8/LC_MESSAGES/plugin_passwd.mo
Normal file
Binary file not shown.
94
language/hu_HU.UTF-8/LC_MESSAGES/plugin_passwd.po
Normal file
94
language/hu_HU.UTF-8/LC_MESSAGES/plugin_passwd.po
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: zarafa-webapp-plugin-passwd\n"
|
||||||
|
"POT-Creation-Date: 2014-03-04 13:53+0100\n"
|
||||||
|
"PO-Revision-Date: 2016-04-08 21:28+0200\n"
|
||||||
|
"Last-Translator: David Horvath <dacr@dacr.hu>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"Language: hu\n"
|
||||||
|
"X-Generator: Poedit 1.8.7.1\n"
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:44:
|
||||||
|
msgid "No data received."
|
||||||
|
msgstr "Nem érkezett adat."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:48:
|
||||||
|
msgid "User name is empty."
|
||||||
|
msgstr "Felhasználónév mező üres."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:52:
|
||||||
|
msgid "Current password is empty."
|
||||||
|
msgstr "Jelenlegi jelszó mező üres."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:56:
|
||||||
|
msgid "New password is empty."
|
||||||
|
msgstr "Új jelszó mező üres."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:60:
|
||||||
|
msgid "New passwords do not match."
|
||||||
|
msgstr "Az új jelszavak nem egyeznek."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:137:
|
||||||
|
# php/class.passwdmodule.php:196:
|
||||||
|
# js/data/PasswdResponseHandler.js:44:
|
||||||
|
msgid "Password is changed successfully."
|
||||||
|
msgstr "A jelszót sikeresen módosította."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:141:
|
||||||
|
# php/class.passwdmodule.php:200:
|
||||||
|
msgid "Password is not changed."
|
||||||
|
msgstr "A jelszó nem módosult."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:144:
|
||||||
|
# php/class.passwdmodule.php:203:
|
||||||
|
msgid ""
|
||||||
|
"Password is weak. Password should contain capital, non-capital letters and "
|
||||||
|
"numbers. Password should have 8 to 20 characters."
|
||||||
|
msgstr ""
|
||||||
|
"A jelszó gyenge. Tartalmaznia kell számot, nagy- és kisbetűt. A jelszó "
|
||||||
|
"minimum 8, maximum 20 karakter legyen."
|
||||||
|
|
||||||
|
# php/class.passwdmodule.php:147:
|
||||||
|
msgid "Current password does not match."
|
||||||
|
msgstr "A jelenlegi jelszó nem megfelelő."
|
||||||
|
|
||||||
|
# js/data/PasswdResponseHandler.js:27:
|
||||||
|
msgid "An unknown error occurred while changing password."
|
||||||
|
msgstr "Ismeretlen hiba történt a jelszó megváltoztatásakor."
|
||||||
|
|
||||||
|
# js/data/PasswdResponseHandler.js:33:
|
||||||
|
msgid "Error"
|
||||||
|
msgstr "Hiba"
|
||||||
|
|
||||||
|
# js/data/PasswdResponseHandler.js:50:
|
||||||
|
msgid "Success"
|
||||||
|
msgstr "Sikeres"
|
||||||
|
|
||||||
|
# js/settings/SettingsPasswdWidget.js:24:
|
||||||
|
# js/settings/SettingsPasswdCategory.js:20:
|
||||||
|
msgid "Change Password"
|
||||||
|
msgstr "Jelszó megváltoztatása"
|
||||||
|
|
||||||
|
# js/PasswdPlugin.js:50:
|
||||||
|
msgid "Password Change Plugin"
|
||||||
|
msgstr "Jelszóváltoztatás kiegészítő"
|
||||||
|
|
||||||
|
# js/settings/PasswdPanel.js:29:
|
||||||
|
msgid "User name"
|
||||||
|
msgstr "Felhasználónév"
|
||||||
|
|
||||||
|
# js/settings/PasswdPanel.js:33:
|
||||||
|
msgid "Current password"
|
||||||
|
msgstr "Jelenlegi jelszó"
|
||||||
|
|
||||||
|
# js/settings/PasswdPanel.js:42:
|
||||||
|
msgid "New password"
|
||||||
|
msgstr "Új jelszó"
|
||||||
|
|
||||||
|
# js/settings/PasswdPanel.js:51:
|
||||||
|
msgid "Retype new password"
|
||||||
|
msgstr "Új jelszó mégegyszer"
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
<!DOCTYPE plugin SYSTEM "manifest.dtd">
|
<!DOCTYPE plugin SYSTEM "manifest.dtd">
|
||||||
<plugin version="2">
|
<plugin version="2">
|
||||||
<info>
|
<info>
|
||||||
<version>1.2</version>
|
<version>1.3</version>
|
||||||
<name>Passwd</name>
|
<name>Passwd</name>
|
||||||
<title>Password Change Plugin</title>
|
<title>Password Change Plugin</title>
|
||||||
<author>Saket Patel</author>
|
<author>Saket Patel</author>
|
||||||
<authorURL>https://github.com/silentsakky</authorURL>
|
<authorURL>https://github.com/silentsakky</authorURL>
|
||||||
<description>Change your password from zarafa webapp</description>
|
<description>Change your password from webapp</description>
|
||||||
</info>
|
</info>
|
||||||
<config>
|
<config>
|
||||||
<configfile>config.php</configfile>
|
<configfile>config.php</configfile>
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
<translationsdir>language</translationsdir>
|
<translationsdir>language</translationsdir>
|
||||||
</translations>
|
</translations>
|
||||||
|
|
||||||
|
|
||||||
<components>
|
<components>
|
||||||
<component>
|
<component>
|
||||||
<files>
|
<files>
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@ class PasswdModule extends Module
|
||||||
public function saveInLDAP($data)
|
public function saveInLDAP($data)
|
||||||
{
|
{
|
||||||
$errorMessage = '';
|
$errorMessage = '';
|
||||||
|
$userName = $data['username'];
|
||||||
|
$newPassword = $data['new_password'];
|
||||||
|
$sessionPass = '';
|
||||||
|
|
||||||
// connect to LDAP server
|
// connect to LDAP server
|
||||||
$ldapconn = ldap_connect(PLUGIN_PASSWD_LDAP_URI);
|
$ldapconn = ldap_connect(PLUGIN_PASSWD_LDAP_URI);
|
||||||
|
|
@ -91,10 +94,10 @@ class PasswdModule extends Module
|
||||||
if(ldap_errno($ldapconn) === 0) {
|
if(ldap_errno($ldapconn) === 0) {
|
||||||
// get the users uid, if we have a multi tenant installation then remove company name from user name
|
// get the users uid, if we have a multi tenant installation then remove company name from user name
|
||||||
if (PLUGIN_PASSWD_LOGIN_WITH_TENANT){
|
if (PLUGIN_PASSWD_LOGIN_WITH_TENANT){
|
||||||
$parts = explode('@', $data['username']);
|
$parts = explode('@', $userName);
|
||||||
$uid = $parts[0];
|
$uid = $parts[0];
|
||||||
} else {
|
} else {
|
||||||
$uid = $data['username'];
|
$uid = $userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we should use tls!
|
// check if we should use tls!
|
||||||
|
|
@ -114,55 +117,47 @@ class PasswdModule extends Module
|
||||||
$ldapconn, // connection-identify
|
$ldapconn, // connection-identify
|
||||||
PLUGIN_PASSWD_LDAP_BASEDN, // basedn
|
PLUGIN_PASSWD_LDAP_BASEDN, // basedn
|
||||||
'uid=' . $uid, // search filter
|
'uid=' . $uid, // search filter
|
||||||
array('dn') // needed attributes. we need the dn
|
array('dn', 'objectClass') // needed attributes. we need dn and objectclass
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($userdn) {
|
if ($userdn) {
|
||||||
$userdn = ldap_get_entries($ldapconn, $userdn);
|
$entries = ldap_get_entries($ldapconn, $userdn);
|
||||||
$userdn = $userdn[0]['dn'];
|
$userdn = $entries[0]['dn'];
|
||||||
|
|
||||||
// bind to ldap directory
|
// bind to ldap directory
|
||||||
// login with current password if that fails then current password is wrong
|
// login with current password if that fails then current password is wrong
|
||||||
ldap_bind($ldapconn, $userdn, $data['current_password']);
|
ldap_bind($ldapconn, $userdn, $data['current_password']);
|
||||||
|
|
||||||
if(ldap_errno($ldapconn) === 0) {
|
if(ldap_errno($ldapconn) === 0) {
|
||||||
|
$password_hash = $this->sshaEncode($newPassword);
|
||||||
|
$entry = array('userPassword' => $password_hash);
|
||||||
|
|
||||||
$passwd = $data['new_password'];
|
if (in_array('sambaSamAccount', $entries[0]['objectclass'])) {
|
||||||
|
$nthash = strtoupper(bin2hex(mhash(MHASH_MD4, iconv("UTF-8", "UTF-16LE", $newPassword))));
|
||||||
|
$entry['sambaNTPassword'] = $nthash;
|
||||||
|
$entry['sambaPwdLastSet'] = strval(time());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->checkPasswordStrenth($passwd)) {
|
ldap_modify($ldapconn, $userdn, $entry);
|
||||||
$password_hash = $this->sshaEncode($passwd);
|
if (ldap_errno($ldapconn) === 0) {
|
||||||
$entry = array('userPassword' => $password_hash);
|
// password changed successfully
|
||||||
ldap_modify($ldapconn, $userdn, $entry);
|
|
||||||
if (ldap_errno($ldapconn) === 0) {
|
|
||||||
// password changed successfully
|
|
||||||
|
|
||||||
// write new password to session because we don't want user to re-authenticate
|
// send feedback to client
|
||||||
session_start();
|
$this->sendFeedback(true, array(
|
||||||
// if user has openssl module installed
|
'info' => array(
|
||||||
if(function_exists("openssl_encrypt")) {
|
'display_message' => dgettext("plugin_passwd", 'Password is changed successfully.')
|
||||||
// In PHP 5.3.3 the iv parameter was added
|
)
|
||||||
if(version_compare(phpversion(), "5.3.3", "<")) {
|
));
|
||||||
$_SESSION['password'] = openssl_encrypt($passwd,"des-ede3-cbc",PASSWORD_KEY,0);
|
|
||||||
} else {
|
|
||||||
$_SESSION['password'] = openssl_encrypt($passwd,"des-ede3-cbc",PASSWORD_KEY,0,PASSWORD_IV);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$_SESSION['password'] = $passwd;
|
|
||||||
}
|
|
||||||
session_write_close();
|
|
||||||
|
|
||||||
// send feedback to client
|
// write new password to session because we don't want user to re-authenticate
|
||||||
$this->sendFeedback(true, array(
|
session_start();
|
||||||
'info' => array(
|
$encryptionStore = EncryptionStore::getInstance();
|
||||||
'display_message' => dgettext("plugin_passwd", 'Password is changed successfully.')
|
$encryptionStore->add('password', $newPassword);
|
||||||
)
|
session_write_close();
|
||||||
));
|
|
||||||
} else {
|
return true;
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Password is not changed.');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Password is weak. Password should contain capital, non-capital letters and numbers. Password should have 8 to 20 characters.');
|
$errorMessage = dgettext("plugin_passwd", 'Password is not changed.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Current password does not match.');
|
$errorMessage = dgettext("plugin_passwd", 'Current password does not match.');
|
||||||
|
|
@ -192,58 +187,47 @@ class PasswdModule extends Module
|
||||||
public function saveInDB($data)
|
public function saveInDB($data)
|
||||||
{
|
{
|
||||||
$errorMessage = '';
|
$errorMessage = '';
|
||||||
$passwd = $data['new_password'];
|
$userName = $data['username'];
|
||||||
|
$newPassword = $data['new_password'];
|
||||||
|
$sessionPass = '';
|
||||||
|
|
||||||
// get current session password
|
// get current session password
|
||||||
$sessionPass = $_SESSION['password'];
|
// if this plugin is used on a webapp version with EncryptionStore,
|
||||||
// if user has openssl module installed
|
// $_SESSION['password'] is no longer available. User EncryptionStore
|
||||||
if (function_exists("openssl_decrypt")) {
|
// in this case.
|
||||||
if (version_compare(phpversion(), "5.3.3", "<")) {
|
// EncryptionStore was introduced in webapp core somewhere after
|
||||||
$sessionPass = openssl_decrypt($sessionPass, "des-ede3-cbc", PASSWORD_KEY, 0);
|
// version 2.1.2, and with or before version 2.2.0.414.
|
||||||
} else {
|
// tested with Zarafa WebApp 2.2.1.43-199.1 running with
|
||||||
$sessionPass = openssl_decrypt($sessionPass, "des-ede3-cbc", PASSWORD_KEY, 0, PASSWORD_IV);
|
// Zarafa Server 7.2.4.29-99.1
|
||||||
}
|
if(class_exists("EncryptionStore")) {
|
||||||
|
$encryptionStore = EncryptionStore::getInstance();
|
||||||
if (!$sessionPass) {
|
$sessionPass = $encryptionStore->get("password");
|
||||||
$sessionPass = $_SESSION['password'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['current_password'] === $sessionPass) {
|
if($data['current_password'] === $sessionPass) {
|
||||||
if ($this->checkPasswordStrenth($passwd)) {
|
// all information correct, change password
|
||||||
// all information correct, change password
|
$store = $GLOBALS['mapisession']->getDefaultMessageStore();
|
||||||
$store = $GLOBALS['mapisession']->getDefaultMessageStore();
|
$userinfo = mapi_zarafa_getuser_by_name($store, $userName);
|
||||||
$userinfo = mapi_zarafa_getuser_by_name($store, $data['username']);
|
|
||||||
|
|
||||||
if (mapi_zarafa_setuser($store, $userinfo['userid'], $data['username'], $userinfo['fullname'], $userinfo['emailaddress'], $passwd, 0, $userinfo['admin'])) {
|
if (mapi_zarafa_setuser($store, $userinfo['userid'], $userName, $userinfo['fullname'], $userinfo['emailaddress'], $newPassword, 0, $userinfo['admin'])) {
|
||||||
// password changed successfully
|
// password changed successfully
|
||||||
|
|
||||||
// write new password to session because we don't want user to re-authenticate
|
// send feedback to client
|
||||||
session_start();
|
$this->sendFeedback(true, array(
|
||||||
// if user has openssl module installed
|
'info' => array(
|
||||||
if (function_exists("openssl_encrypt")) {
|
'display_message' => dgettext("plugin_passwd", 'Password is changed successfully.')
|
||||||
// In PHP 5.3.3 the iv parameter was added
|
)
|
||||||
if (version_compare(phpversion(), "5.3.3", "<")) {
|
));
|
||||||
$_SESSION['password'] = openssl_encrypt($passwd, "des-ede3-cbc", PASSWORD_KEY, 0);
|
|
||||||
} else {
|
|
||||||
$_SESSION['password'] = openssl_encrypt($passwd, "des-ede3-cbc", PASSWORD_KEY, 0, PASSWORD_IV);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$_SESSION['password'] = $passwd;
|
|
||||||
}
|
|
||||||
session_write_close();
|
|
||||||
|
|
||||||
// send feedback to client
|
// write new password to session because we don't want user to re-authenticate
|
||||||
$this->sendFeedback(true, array(
|
session_start();
|
||||||
'info' => array(
|
$encryptionStore = EncryptionStore::getInstance();
|
||||||
'display_message' => dgettext("plugin_passwd", 'Password is changed successfully.')
|
$encryptionStore->add('password', $newPassword);
|
||||||
)
|
session_write_close();
|
||||||
));
|
|
||||||
} else {
|
return true;
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Password is not changed.');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Password is weak. Password should contain capital, non-capital letters and numbers. Password should have 8 to 20 characters.');
|
$errorMessage = dgettext("plugin_passwd", 'Password is not changed.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = dgettext("plugin_passwd", 'Current password does not match.');
|
$errorMessage = dgettext("plugin_passwd", 'Current password does not match.');
|
||||||
|
|
@ -259,25 +243,6 @@ class PasswdModule extends Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function will check strength of the password and if it does not meet minimum requirements then
|
|
||||||
* will return false.
|
|
||||||
* Password should meet the following criteria:
|
|
||||||
* - min. 8 chars, max. 20
|
|
||||||
* - contain caps and noncaps characters
|
|
||||||
* - contain numbers
|
|
||||||
* @param {String} $password password which should be checked.
|
|
||||||
* @return {Boolean} true if password passes the minimum requirement else false.
|
|
||||||
*/
|
|
||||||
public function checkPasswordStrenth($password)
|
|
||||||
{
|
|
||||||
if (preg_match("#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$#", $password)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function will generate SSHA hash to use to store user's password in LDAP.
|
* Function will generate SSHA hash to use to store user's password in LDAP.
|
||||||
* @param {String} $text text based on which hash will be generated.
|
* @param {String} $text text based on which hash will be generated.
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ class Pluginpasswd extends Plugin {
|
||||||
'v1' => Array(
|
'v1' => Array(
|
||||||
'plugins' => Array(
|
'plugins' => Array(
|
||||||
'passwd' => Array(
|
'passwd' => Array(
|
||||||
'enable' => PLUGIN_PASSWD_USER_DEFAULT_ENABLE,
|
'enable' => PLUGIN_PASSWD_USER_DEFAULT_ENABLE,
|
||||||
|
'enable_strict_check' => PLUGIN_PASSWD_STRICT_CHECK_ENABLE,
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue