source: subversion/trunk/plugins/password/README @ 3850

Last change on this file since 3850 was 3850, checked in by alec, 3 years ago
  • Added ldap_simple driver
File size: 8.3 KB
Line 
1 -----------------------------------------------------------------------
2 Password Plugin for Roundcube
3 -----------------------------------------------------------------------
4
5 Plugin that adds a possibility to change user password using many
6 methods (drivers) via Settings/Password tab.
7
8 -----------------------------------------------------------------------
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 2
11 as published by the Free Software Foundation.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 @version @package_version@
23 @author Aleksander 'A.L.E.C' Machniak <alec@alec.pl>
24 @author <see driver files for driver authors>
25 -----------------------------------------------------------------------
26
27 1.     Configuration
28 2.     Drivers
29 2.1.   Database (sql)
30 2.2.   Cyrus/SASL (sasl)
31 2.3.   Poppassd/Courierpassd (poppassd)
32 2.4.   LDAP (ldap)
33 2.5.   DirectAdmin Control Panel (directadmin)
34 2.6.   cPanel (cpanel)
35 2.7.   XIMSS/Communigate (ximms)
36 2.8.   Virtualmin (virtualmin)
37 2.9.   hMailServer (hmail)
38 2.10.  PAM (pam)
39 2.11.  Chpasswd (chpasswd)
40 2.12.  LDAP - no PEAR (ldap_simple)
41 3.     Driver API
42
43
44 1. Configuration
45 ----------------
46
47 Copy config.inc.php.dist to config.inc.php and set the options as described
48 within the file.
49
50
51 2. Drivers
52 ----------
53
54 Password plugin supports many password change mechanisms which are
55 handled by included drivers. Just pass driver name in 'password_driver' option.
56
57
58 2.1. Database (sql)
59 -------------------
60
61 You can specify which database to connect by 'password_db_dsn' option and
62 what SQL query to execute by 'password_query'. See main.inc.php file for
63 more info.
64
65 Example implementations of an update_passwd function:
66
67 - This is for use with LMS (http://lms.org.pl) database and postgres:
68
69        CREATE OR REPLACE FUNCTION update_passwd(hash text, account text) RETURNS integer AS $$
70        DECLARE
71            res integer;
72        BEGIN
73            UPDATE passwd SET password = hash
74            WHERE login = split_part(account, '@', 1)
75                AND domainid = (SELECT id FROM domains WHERE name = split_part(account, '@', 2))
76            RETURNING id INTO res;
77            RETURN res;
78        END;
79        $$ LANGUAGE plpgsql SECURITY DEFINER;
80
81 - This is for use with a SELECT update_passwd(%o,%c,%u) query
82        Updates the password only when the old password matches the MD5 password
83        in the database
84
85        CREATE FUNCTION update_password (oldpass text, cryptpass text, user text) RETURNS text
86            MODIFIES SQL DATA
87        BEGIN
88            DECLARE currentsalt varchar(20);
89            DECLARE error text;
90            SET error = 'incorrect current password';
91            SELECT substring_index(substr(user.password,4),_latin1'$',1) INTO currentsalt FROM users WHERE username=user;
92            SELECT '' INTO error FROM users WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
93            UPDATE users SET password=cryptpass WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
94            RETURN error;
95        END
96
97 Example SQL UPDATEs:
98
99 - Plain text passwords:
100    UPDATE users SET password=%p WHERE username=%u AND password=%o AND domain=%h LIMIT 1
101
102 - Crypt text passwords:
103    UPDATE users SET password=%c WHERE username=%u LIMIT 1
104
105 - Use a MYSQL crypt function (*nix only) with random 8 character salt
106    UPDATE users SET password=ENCRYPT(%p,concat(_utf8'$1$',right(md5(rand()),8),_utf8'$')) WHERE username=%u LIMIT 1
107
108 - MD5 stored passwords:
109    UPDATE users SET password=MD5(%p) WHERE username=%u AND password=MD5(%o) LIMIT 1
110
111
112 2.2. Cyrus/SASL (sasl)
113 ----------------------
114
115 Cyrus SASL database authentication allows your Cyrus+RoundCube
116 installation to host mail users without requiring a Unix Shell account!
117
118 This driver only covers the "sasldb" case when using Cyrus SASL. Kerberos
119 and PAM authentication mechanisms will require other techniques to enable
120 user password manipulations.
121
122 Cyrus SASL includes a shell utility called "saslpasswd" for manipulating
123 user passwords in the "sasldb" database.  This plugin attempts to use
124 this utility to perform password manipulations required by your webmail
125 users without any administrative interaction. Unfortunately, this
126 scheme requires that the "saslpasswd" utility be run as the "cyrus"
127 user - kind of a security problem since we have chosen to SUID a small
128 script which will allow this to happen.
129
130 This driver is based on the Squirrelmail Change SASL Password Plugin.
131 See http://www.squirrelmail.org/plugin_view.php?id=107 for details.
132
133 Installation:
134
135 Change into the drivers directory. Edit the chgsaslpasswd.c file as is
136 documented within it.
137
138 Compile the wrapper program:
139        gcc -o chgsaslpasswd chgsaslpasswd.c
140
141 Chown the compiled chgsaslpasswd binary to the cyrus user and group
142 that your browser runs as, then chmod them to 4550.
143
144 For example, if your cyrus user is 'cyrus' and the apache server group is
145 'nobody' (I've been told Redhat runs Apache as user 'apache'):
146
147        chown cyrus:nobody chgsaslpasswd
148        chmod 4550 chgsaslpasswd
149
150 Stephen Carr has suggested users should try to run the scripts on a test
151 account as the cyrus user eg;
152
153        su cyrus -c "./chgsaslpasswd -p test_account"
154
155 This will allow you to make sure that the script will work for your setup.
156 Should the script not work, make sure that:
157 1) the user the script runs as has access to the saslpasswd|saslpasswd2
158   file and proper permissions
159 2) make sure the user in the chgsaslpasswd.c file is set correctly.
160   This could save you some headaches if you are the paranoid type.
161
162
163 2.3. Poppassd/Courierpassd (poppassd)
164 -------------------------------------
165
166 You can specify which host to connect to via 'password_pop_host' and
167 what port via 'password_pop_port'. See config.inc.php file for more info.
168
169
170 2.4. LDAP (ldap)
171 ----------------
172
173 See config.inc.php file. Requires PEAR::Net_LDAP2 package.
174
175
176 2.5. DirectAdmin Control Panel (directadmin)
177 --------------------------------------------
178
179 You can specify which host to connect to via 'password_directadmin_host'
180 and what port via 'password_direactadmin_port'. See config.inc.php file
181 for more info.
182
183
184 2.6. cPanel (cpanel)
185 --------------------
186
187 You can specify parameters for HTTP connection to cPanel's admin
188 interface. See config.inc.php file for more info.
189
190
191 2.7. XIMSS/Communigate (ximms)
192 ------------------------------
193
194 You can specify which host and port to connect to via 'password_ximss_host'
195 and 'password_ximss_port'. See config.inc.php file for more info.
196
197
198 2.8. Virtualmin (virtualmin)
199 ----------------------------
200
201 As in sasl driver this one allows to change password using shell
202 utility called "virtualmin". See drivers/chgvirtualminpasswd.c for
203 installation instructions.
204
205
206 2.9. hMailServer (hmail)
207 ------------------------
208 
209 Requires PHP COM (Windows only).
210
211
212 2.10. PAM (pam)
213 ---------------
214 
215 This driver is for changing passwords of shell users authenticated with PAM.
216 Requires PECL's PAM exitension to be installed (http://pecl.php.net/package/PAM).
217
218
219 2.11. Chpasswd (chpasswd)
220 -------------------------
221 
222 Driver that adds functionality to change the systems user password via
223 the 'chpasswd' command. See config.inc.php file.
224
225
226 2.12.  LDAP - no PEAR (ldap_simple)
227 -----------------------------------
228
229 It's rewritten ldap driver that doesn't require the Net_LDAP2 PEAR extension.
230 It uses directly PHP's ldap module functions instead (as Roundcube does).
231
232 This driver is fully compatible with the ldap driver, but
233 does not require (or uses) the
234    $rcmail_config['password_ldap_force_replace'] variable.
235 Other advantages:
236    * Connects only once with the LDAP server when using the search user.
237    * Does not read the DN, but only replaces the password within (that is
238      why the 'force replace' is always used).
239
240
241 3. Driver API
242 -------------
243
244 Driver file (<driver_name>.php) must define 'password_save' function with
245 two arguments. First - current password, second - new password. Function
246 may return PASSWORD_SUCCESS on success or any of PASSWORD_CONNECT_ERROR,
247 PASSWORD_CRYPT_ERROR, PASSWORD_ERROR when driver was unable to change password.
248 See existing drivers in drivers/ directory for examples.
Note: See TracBrowser for help on using the repository browser.