Skip to content

Commit 49f5815

Browse files
committed
Merge branch 'release/v4.2.0'
2 parents ac86cf8 + 3608e6f commit 49f5815

32 files changed

+437
-44
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ 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.2.0] - 2018-12-16
8+
### Added
9+
- Support for Nextcloud 15
10+
- Redmine, SHA-256, SHA-512 hash algorithms
11+
### Fixed
12+
- Loading user list when display name is null
13+
- Hide "password change form" when "Allow password change" not set
14+
### Changed
15+
- Append salt only when checked. Not by default
16+
717
## [4.1.0] - 2018-10-28
818
### Added
919
- Whirlpool hash algorithm
@@ -98,6 +108,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
98108
### Changed
99109
- Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12
100110

111+
[4.2.0]: https://github.com/nextcloud/user_sql/compare/v4.1.0...v4.2.0
101112
[4.1.0]: https://github.com/nextcloud/user_sql/compare/v4.0.1...v4.1.0
102113
[4.0.1]: https://github.com/nextcloud/user_sql/compare/v4.0.0...v4.0.1
103114
[4.0.0]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc2...v4.0.0

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ Name | Description | Details
7373
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
7474
**Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
7575
**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.
76+
**Append salt** | Append a salt to the password. | Optional.<br/>Default: false.
77+
**Prepend salt** | Prepend a salt to the password. | Optional.<br/>Default: false.
7778

7879
#### Group table
7980

@@ -119,7 +120,8 @@ CREATE TABLE sql_user
119120
home TEXT NULL,
120121
password TEXT NOT NULL,
121122
active TINYINT(1) NOT NULL DEFAULT '1',
122-
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE
123+
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE,
124+
salt TEXT NULL
123125
);
124126
125127
CREATE TABLE sql_group
@@ -195,15 +197,22 @@ Drupal 7 | See [phpass](http://www.openwall.com/phpass/). | $S$DC7eCpJQ3SUQtW4Bp
195197
Joomla MD5 Encryption | Generates 32 chars salt. | 14d21b49b0f13e2acba962b6b0039edd:haJK0yTvBXTNMh76xwEw5RYEVpJsN8us
196198
MD5 | No salt supported. | 5f4dcc3b5aa765d61d8327deb882cf99
197199
Portable PHP password | See [phpass](http://www.openwall.com/phpass/). | $P$BxrwraqNTi4as0EI.IpiA/K.muk9ke/
198-
SHA1 | No salt supported. | 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
199-
SHA512 Whirlpool | No salt supported. | a96b16ebb691dbe968b0d66d0d924cff5cf5de5e0885181d00761d87f295b2bf3d3c66187c050fc01c196ff3acaa48d3561ffd170413346e934a32280d632f2e
200+
Redmine | Requires salt. Salt value for hash in the next column is 'salt'. | 48b75edeffd8e413341d7734f0f3391e7a5da994
201+
SHA-1 | No salt supported. | 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
202+
SHA-256 | No salt supported. | 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
203+
SHA-512 | No salt supported. | b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86
204+
SHA-512 Whirlpool | No salt supported. | a96b16ebb691dbe968b0d66d0d924cff5cf5de5e0885181d00761d87f295b2bf3d3c66187c050fc01c196ff3acaa48d3561ffd170413346e934a32280d632f2e
200205
SSHA256 | Generates 32 chars salt. | {SSHA256}+WxTB3JxprNteeovsuSYtgI+UkVPA9lfwGoYkz3Ff7hjd1FSdmlTMkNsSExyR21KM3NvNTZ5V0p4WXJMUjFzUg==
201206
SSHA512 | Generates 32 chars salt. | {SSHA512}It+v1kAEUBbhMJYJ2swAtz+RLE6ispv/FB6G/ALhK/YWwEmrloY+0jzrWIfmu+rWUXp8u0Tg4jLXypC5oXAW00IyYnRVdEZJbE9wak96bkNRVWFCYmlJNWxrdTA0QmhL
202207
WoltLab Community Framework 2.x | Double salted bcrypt. | $2a$08$XEQDKNU/Vbootwxv5Gp7gujxFX/RUFsZLvQPYM435Dd3/p17fto02
203208
Whirlpool | | 74dfc2b27acfa364da55f93a5caee29ccad3557247eda238831b3e9bd931b01d77fe994e4f12b9d4cfa92a124461d2065197d8cf7f33fc88566da2db2a4d6eae
204209

205210
## Development
206211

212+
#### Testing environment
213+
214+
There is a [vagrant](https://github.com/mlojewski-me/user_sql-vagrant) box which you can use at development stage.
215+
207216
#### New database driver support
208217

209218
Add a new class in the `OCA\UserSQL\Platform` namespace which extends the `AbstractPlatform` class.

appinfo/info.xml

Lines changed: 2 additions & 2 deletions
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.1.0</version>
11+
<version>4.2.0</version>
1212
<licence>agpl</licence>
1313
<author>Marcin Łojewski</author>
1414
<author>Andreas Böhler</author>
@@ -22,7 +22,7 @@
2222
<category>auth</category>
2323
<dependencies>
2424
<php min-version="7.0"/>
25-
<nextcloud min-version="14" max-version="14"/>
25+
<nextcloud min-version="14" max-version="15"/>
2626
</dependencies>
2727
<settings>
2828
<admin>\OCA\UserSQL\Settings\Admin</admin>

lib/Backend/UserBackend.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
namespace OCA\UserSQL\Backend;
2323

24+
use OC\User\Backend;
2425
use OCA\UserSQL\Action\EmailSync;
2526
use OCA\UserSQL\Action\IUserAction;
2627
use OCA\UserSQL\Action\QuotaSync;
@@ -263,6 +264,10 @@ public function getDisplayName($uid): string
263264
return false;
264265
}
265266

267+
if (is_null($user->name)) {
268+
return false;
269+
}
270+
266271
$name = $user->name;
267272
$this->logger->debug(
268273
"Returning getDisplayName($uid): $name",
@@ -302,7 +307,7 @@ public function checkPassword(string $uid, string $password)
302307
$password = $this->addSalt($user, $password);
303308

304309
$isCorrect = $passwordAlgorithm->checkPassword(
305-
$password, $user->password
310+
$password, $user->password, $user->salt
306311
);
307312

308313
if ($user->active == false) {
@@ -361,9 +366,9 @@ private function getPasswordAlgorithm()
361366
private function addSalt(User $user, string $password): string
362367
{
363368
if ($user->salt !== null) {
364-
if (empty($this->properties[Opt::PREPEND_SALT])) {
369+
if (!empty($this->properties[Opt::APPEND_SALT])) {
365370
return $password . $user->salt;
366-
} else {
371+
} elseif (!empty($this->properties[Opt::PREPEND_SALT])) {
367372
return $user->salt . $password;
368373
}
369374
}
@@ -389,7 +394,9 @@ public function getDisplayNames($search = "", $limit = null, $offset = null)
389394

390395
$names = [];
391396
foreach ($users as $user) {
392-
$names[$user] = $user->name;
397+
if (!is_null($user->name)) {
398+
$names[$user] = $user->name;
399+
}
393400
}
394401

395402
$this->logger->debug(
@@ -636,4 +643,16 @@ public function deleteUser($uid)
636643
{
637644
return false;
638645
}
646+
647+
/**
648+
* @inheritdoc
649+
*/
650+
public function implementsActions($actions): bool
651+
{
652+
if ($actions & Backend::SET_PASSWORD) {
653+
return !empty($this->properties[Opt::PASSWORD_CHANGE]);
654+
}
655+
656+
return parent::implementsActions($actions);
657+
}
639658
}

lib/Constant/Opt.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
final class Opt
3030
{
31+
const APPEND_SALT = "opt.append_salt";
3132
const CASE_INSENSITIVE_USERNAME = "opt.case_insensitive_username";
3233
const CRYPTO_CLASS = "opt.crypto_class";
3334
const EMAIL_SYNC = "opt.email_sync";

lib/Crypto/AbstractAlgorithm.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ protected abstract function getAlgorithmName();
6565
/**
6666
* @inheritdoc
6767
*/
68-
public function checkPassword($password, $dbHash)
68+
public function checkPassword($password, $dbHash, $salt = null)
6969
{
70-
return hash_equals($dbHash, $this->getPasswordHash($password));
70+
return hash_equals($dbHash, $this->getPasswordHash($password, $salt));
7171
}
7272

7373
/**
7474
* @inheritdoc
7575
*/
76-
public abstract function getPasswordHash($password);
76+
public abstract function getPasswordHash($password, $salt = null);
7777
}

lib/Crypto/AbstractCrypt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ abstract class AbstractCrypt extends AbstractAlgorithm
3838
/**
3939
* @inheritdoc
4040
*/
41-
public function checkPassword($password, $dbHash)
41+
public function checkPassword($password, $dbHash, $salt = null)
4242
{
4343
return hash_equals($dbHash, crypt($password, $dbHash));
4444
}
4545

4646
/**
4747
* @inheritdoc
4848
*/
49-
public function getPasswordHash($password)
49+
public function getPasswordHash($password, $salt = null)
5050
{
5151
return crypt($password, $this->getSalt());
5252
}

lib/Crypto/Cleartext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(IL10N $localization)
4343
/**
4444
* @inheritdoc
4545
*/
46-
public function getPasswordHash($password)
46+
public function getPasswordHash($password, $salt = null)
4747
{
4848
return $password;
4949
}

lib/Crypto/CourierMD5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(IL10N $localization)
4343
/**
4444
* @inheritdoc
4545
*/
46-
public function getPasswordHash($password)
46+
public function getPasswordHash($password, $salt = null)
4747
{
4848
return '{MD5}' . Utils::hexToBase64(md5($password));
4949
}

lib/Crypto/CourierMD5Raw.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(IL10N $localization)
4343
/**
4444
* @inheritdoc
4545
*/
46-
public function getPasswordHash($password)
46+
public function getPasswordHash($password, $salt = null)
4747
{
4848
return '{MD5RAW}' . md5($password);
4949
}

0 commit comments

Comments
 (0)