Skip to content

Commit ac86cf8

Browse files
committed
Merge branch 'release/v4.1.0'
2 parents e676ed1 + 949543c commit ac86cf8

20 files changed

Lines changed: 403 additions & 53 deletions

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## [4.0.1] - 2018-08-11
7+
## [4.1.0] - 2018-10-28
8+
### Added
9+
- Whirlpool hash algorithm
10+
- 'Prepend salt' toggle
11+
- Drupal 7 hash algorithm
12+
- 'Case-insensitive username' option
13+
### Fixed
14+
- Error when 'Display name' not set
15+
- Encoding of iteration for 'Extended DES (Crypt)'
16+
- 'Trying to get property of non-object' warning
17+
18+
## [4.0.1] - 2018-08-16
819
### Fixed
920
- Leftover lines break the admin page
1021

@@ -87,6 +98,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
8798
### Changed
8899
- Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12
89100

101+
[4.1.0]: https://github.com/nextcloud/user_sql/compare/v4.0.1...v4.1.0
90102
[4.0.1]: https://github.com/nextcloud/user_sql/compare/v4.0.0...v4.0.1
91103
[4.0.0]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc2...v4.0.0
92104
[4.0.0-rc2]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc1...v4.0.0-rc2

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Name | Description | Details
4949
--- | --- | ---
5050
**Allow display name change** | With this option enabled user can change its display name. The display name change is propagated to the database. | Optional.<br/>Default: false.<br/>Requires: user *Display name* column.
5151
**Allow password change** | Can user change its password. The password change is propagated to the database. See [Hash algorithms](#hash-algorithms). | Optional.<br/>Default: false.
52+
**Case-insensitive username** | Whether user query should be case-sensitive or case-insensitive. | Optional.<br/>Default: false.
5253
**Use cache** | Use database query results cache. The cache can be cleared any time with the *Clear cache* button click. | Optional.<br/>Default: false.
5354
**Hash algorithm** | How users passwords are stored in the database. See [Hash algorithms](#hash-algorithms). | Mandatory.
5455
**Email sync** | Sync e-mail address with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the e-mail address to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the e-mail address to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the e-mail address to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Email* column.
@@ -72,6 +73,7 @@ Name | Description | Details
7273
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
7374
**Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
7475
**Salt** | Salt which is appended to password when checking or changing the password. | Optional.
76+
**Prepend salt** | Prepend a salt to the password instead of appending it. | Optional.<br/>Default: false.
7577

7678
#### Group table
7779

@@ -184,11 +186,12 @@ Courier base64-encoded SHA256 | No salt supported. | {SHA256}XohImNooBHFR0OVvjcY
184186
Unix (Crypt) | See [crypt](http://php.net/manual/en/function.crypt.php). | $2y$10$5rsN1fmoSkaRy9bqhozAXOr0mn0QiVIfd2L04Bbk1Go9MjdvotwBq
185187
Argon2 (Crypt) | Requires PHP >= 7.2.<br/>Uses default parameters. See [password_hash](http://php.net/manual/en/function.password-hash.php). | $argon2i$v=19$m=1024,t=2,p=2$NnpSNlRNLlZobnJHUDh0Sw$oW5E1cfdPzLWfkTvQFUyzTR00R0aLwEdYwldcqW6Pmo
186188
Blowfish (Crypt) | Uses default parameters. See [password_hash](http://php.net/manual/en/function.password-hash.php). | $2y$10$5rsN1fmoSkaRy9bqhozAXOr0mn0QiVIfd2L04Bbk1Go9MjdvotwBq
187-
Extended DES (Crypt) | | ..UZoIyj/Hy/c
189+
Extended DES (Crypt) | | cDRpdxPmHpzS.
188190
MD5 (Crypt) | | $1$RzaFbNcU$u9adfTY/Q6za6nu0Ogrl1/
189191
SHA256 (Crypt) | Generates hash with 5000 rounds. | $5$rounds=5000$VIYD0iHkg7uY9SRc$v2XLS/9dvfFN84mzGvW9wxnVt9Xd/urXaaTkpW8EwD1
190192
SHA512 (Crypt) | Generates hash with 5000 rounds. | $6$rounds=5000$yH.Q0OL4qbCOUJ3q$Xry5EVFva3wKnfo8/ktrugmBd8tcl34NK6rXInv1HhmdSUNLEm0La9JnA57rqwQ.9/Bz513MD4tvmmISLUIHs/
191193
Standard DES (Crypt) | | yTBnb7ab/N072
194+
Drupal 7 | See [phpass](http://www.openwall.com/phpass/). | $S$DC7eCpJQ3SUQtW4Bp.vKb2rpeaffi4iqk9OpYwJyEoSMsezn67Sl
192195
Joomla MD5 Encryption | Generates 32 chars salt. | 14d21b49b0f13e2acba962b6b0039edd:haJK0yTvBXTNMh76xwEw5RYEVpJsN8us
193196
MD5 | No salt supported. | 5f4dcc3b5aa765d61d8327deb882cf99
194197
Portable PHP password | See [phpass](http://www.openwall.com/phpass/). | $P$BxrwraqNTi4as0EI.IpiA/K.muk9ke/
@@ -197,6 +200,7 @@ SHA512 Whirlpool | No salt supported. | a96b16ebb691dbe968b0d66d0d924cff5cf5de5e
197200
SSHA256 | Generates 32 chars salt. | {SSHA256}+WxTB3JxprNteeovsuSYtgI+UkVPA9lfwGoYkz3Ff7hjd1FSdmlTMkNsSExyR21KM3NvNTZ5V0p4WXJMUjFzUg==
198201
SSHA512 | Generates 32 chars salt. | {SSHA512}It+v1kAEUBbhMJYJ2swAtz+RLE6ispv/FB6G/ALhK/YWwEmrloY+0jzrWIfmu+rWUXp8u0Tg4jLXypC5oXAW00IyYnRVdEZJbE9wak96bkNRVWFCYmlJNWxrdTA0QmhL
199202
WoltLab Community Framework 2.x | Double salted bcrypt. | $2a$08$XEQDKNU/Vbootwxv5Gp7gujxFX/RUFsZLvQPYM435Dd3/p17fto02
203+
Whirlpool | | 74dfc2b27acfa364da55f93a5caee29ccad3557247eda238831b3e9bd931b01d77fe994e4f12b9d4cfa92a124461d2065197d8cf7f33fc88566da2db2a4d6eae
200204

201205
## Development
202206

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Retrieve the users and groups info. Allow the users to change their passwords.
99
Sync the users' email addresses with the addresses stored by Nextcloud.
1010
</description>
11-
<version>4.0.1</version>
11+
<version>4.1.0</version>
1212
<licence>agpl</licence>
1313
<author>Marcin Łojewski</author>
1414
<author>Andreas Böhler</author>

img/screenshot.png

2.66 KB
Loading

lib/Action/EmailSync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function doAction(User $user)
111111
}
112112

113113
$user->email = $ncMail;
114-
$result = $this->userRepository->save($user);
114+
$result = $this->userRepository->save($user, UserRepository::EMAIL_FIELD);
115115
}
116116

117117
break;

lib/Action/QuotaSync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function doAction(User $user)
111111
}
112112

113113
$user->quota = $ncQuota;
114-
$result = $this->userRepository->save($user);
114+
$result = $this->userRepository->save($user, UserRepository::QUOTA_FIELD);
115115
}
116116

117117
break;

lib/Backend/GroupBackend.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,6 @@ public function getGroupDetails(string $gid): array
403403
"Entering getGroupDetails($gid)", ["app" => $this->appName]
404404
);
405405

406-
if (empty($this->properties[DB::GROUP_NAME_COLUMN])) {
407-
return [];
408-
}
409-
410406
$group = $this->getGroup($gid);
411407

412408
if (!($group instanceof Group)) {

lib/Backend/UserBackend.php

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,14 @@ public function checkPassword(string $uid, string $password)
292292
return false;
293293
}
294294

295-
$user = $this->userRepository->findByUid($uid);
296-
if (!($user instanceof User)) {
295+
$caseSensitive = empty($this->properties[Opt::CASE_INSENSITIVE_USERNAME]);
296+
$user = $this->userRepository->findByUid($uid, $caseSensitive);
297+
if (!($user instanceof User) || ($caseSensitive && $user->uid !== $uid)) {
297298
return false;
298299
}
299300

300-
if ($user->salt !== null) {
301-
$password .= $user->salt;
302-
}
301+
$uid = $user->uid;
302+
$password = $this->addSalt($user, $password);
303303

304304
$isCorrect = $passwordAlgorithm->checkPassword(
305305
$password, $user->password
@@ -350,6 +350,27 @@ private function getPasswordAlgorithm()
350350
return $passwordAlgorithm;
351351
}
352352

353+
/**
354+
* Append or prepend salt from external column if available.
355+
*
356+
* @param User $user The user instance.
357+
* @param string $password The password.
358+
*
359+
* @return string Salted password.
360+
*/
361+
private function addSalt(User $user, string $password): string
362+
{
363+
if ($user->salt !== null) {
364+
if (empty($this->properties[Opt::PREPEND_SALT])) {
365+
return $password . $user->salt;
366+
} else {
367+
return $user->salt . $password;
368+
}
369+
}
370+
371+
return $password;
372+
}
373+
353374
/**
354375
* @inheritdoc
355376
*/
@@ -368,7 +389,7 @@ public function getDisplayNames($search = "", $limit = null, $offset = null)
368389

369390
$names = [];
370391
foreach ($users as $user) {
371-
$names[$user->uid] = $user->name;
392+
$names[$user] = $user->name;
372393
}
373394

374395
$this->logger->debug(
@@ -457,17 +478,15 @@ public function setPassword(string $uid, string $password): bool
457478
return false;
458479
}
459480

460-
if ($user->salt !== null) {
461-
$password .= $user->salt;
462-
}
481+
$password = $this->addSalt($user, $password);
463482

464483
$passwordHash = $passwordAlgorithm->getPasswordHash($password);
465484
if ($passwordHash === false) {
466485
return false;
467486
}
468487

469488
$user->password = $passwordHash;
470-
$result = $this->userRepository->save($user);
489+
$result = $this->userRepository->save($user, UserRepository::PASSWORD_FIELD);
471490

472491
if ($result === true) {
473492
$this->logger->info(
@@ -571,7 +590,7 @@ public function setDisplayName(string $uid, string $displayName): bool
571590
}
572591

573592
$user->name = $displayName;
574-
$result = $this->userRepository->save($user);
593+
$result = $this->userRepository->save($user, UserRepository::DISPLAY_NAME_FIELD);
575594

576595
if ($result === true) {
577596
$this->logger->info(

lib/Constant/Opt.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
*/
2929
final class Opt
3030
{
31+
const CASE_INSENSITIVE_USERNAME = "opt.case_insensitive_username";
3132
const CRYPTO_CLASS = "opt.crypto_class";
3233
const EMAIL_SYNC = "opt.email_sync";
3334
const HOME_LOCATION = "opt.home_location";
3435
const HOME_MODE = "opt.home_mode";
3536
const NAME_CHANGE = "opt.name_change";
3637
const PASSWORD_CHANGE = "opt.password_change";
38+
const PREPEND_SALT = "opt.prepend_salt";
3739
const QUOTA_SYNC = "opt.quota_sync";
3840
const USE_CACHE = "opt.use_cache";
3941
}

lib/Constant/Query.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ final class Query
3535
const FIND_GROUP_USERS = "find_group_users";
3636
const FIND_GROUPS = "find_groups";
3737
const FIND_USER = "find_user";
38+
const FIND_USER_CASE_INSENSITIVE = "find_user_case_insensitive";
3839
const FIND_USER_GROUPS = "find_user_groups";
3940
const FIND_USERS = "find_users";
40-
const SAVE_USER = "save_user";
41+
const UPDATE_DISPLAY_NAME = "update_display_name";
42+
const UPDATE_EMAIL = "update_email";
43+
const UPDATE_PASSWORD = "update_password";
44+
const UPDATE_QUOTA = "update_quota";
4145

4246
const EMAIL_PARAM = "email";
4347
const GID_PARAM = "gid";

0 commit comments

Comments
 (0)