Skip to content

Commit 602390b

Browse files
committed
mergre current develop
2 parents 1b0467d + 55797f0 commit 602390b

33 files changed

Lines changed: 501 additions & 91 deletions

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ 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+
## [Unreleased]
8+
### Added
9+
- Reverse active column option
10+
- Support for Nextcloud 16
11+
12+
## [4.2.1] - 2018-12-22
13+
### Fixed
14+
- SQL error when same column names given in several tables
15+
16+
## [4.2.0] - 2018-12-16
17+
### Added
18+
- Support for Nextcloud 15
19+
- Redmine, SHA-256, SHA-512 hash algorithms
20+
### Fixed
21+
- Loading user list when display name is null
22+
- Hide "password change form" when "Allow password change" not set
23+
### Changed
24+
- Append salt only when checked. Not by default
25+
726
## [4.1.0] - 2018-10-28
827
### Added
928
- Whirlpool hash algorithm
@@ -98,6 +117,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
98117
### Changed
99118
- Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12
100119

120+
[Unreleased]: https://github.com/nextcloud/user_sql/compare/v4.2.1...develop
121+
[4.2.1]: https://github.com/nextcloud/user_sql/compare/v4.2.0...v4.2.1
122+
[4.2.0]: https://github.com/nextcloud/user_sql/compare/v4.1.0...v4.2.0
101123
[4.1.0]: https://github.com/nextcloud/user_sql/compare/v4.0.1...v4.1.0
102124
[4.0.1]: https://github.com/nextcloud/user_sql/compare/v4.0.0...v4.0.1
103125
[4.0.0]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc2...v4.0.0

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Name | Description | Details
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.
5252
**Case-insensitive username** | Whether user query should be case-sensitive or case-insensitive. | Optional.<br/>Default: false.
53+
**Reverse active column** | Reverse value of active column in user table. | Optional.<br/>Default: false.
5354
**Use cache** | Use database query results cache. The cache can be cleared any time with the *Clear cache* button click. | Optional.<br/>Default: false.
5455
**Hash algorithm** | How users passwords are stored in the database. See [Hash algorithms](#hash-algorithms). | Mandatory.
5556
**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.
@@ -73,7 +74,8 @@ Name | Description | Details
7374
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
7475
**Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
7576
**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.
77+
**Append salt** | Append a salt to the password. | Optional.<br/>Default: false.
78+
**Prepend salt** | Prepend a salt to the password. | Optional.<br/>Default: false.
7779

7880
#### Group table
7981

@@ -119,7 +121,8 @@ CREATE TABLE sql_user
119121
home TEXT NULL,
120122
password TEXT NOT NULL,
121123
active TINYINT(1) NOT NULL DEFAULT '1',
122-
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE
124+
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE,
125+
salt TEXT NULL
123126
);
124127
125128
CREATE TABLE sql_group
@@ -195,15 +198,22 @@ Drupal 7 | See [phpass](http://www.openwall.com/phpass/). | $S$DC7eCpJQ3SUQtW4Bp
195198
Joomla MD5 Encryption | Generates 32 chars salt. | 14d21b49b0f13e2acba962b6b0039edd:haJK0yTvBXTNMh76xwEw5RYEVpJsN8us
196199
MD5 | No salt supported. | 5f4dcc3b5aa765d61d8327deb882cf99
197200
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
201+
Redmine | Requires salt. Salt value for hash in the next column is 'salt'. | 48b75edeffd8e413341d7734f0f3391e7a5da994
202+
SHA-1 | No salt supported. | 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
203+
SHA-256 | No salt supported. | 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
204+
SHA-512 | No salt supported. | b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86
205+
SHA-512 Whirlpool | No salt supported. | a96b16ebb691dbe968b0d66d0d924cff5cf5de5e0885181d00761d87f295b2bf3d3c66187c050fc01c196ff3acaa48d3561ffd170413346e934a32280d632f2e
200206
SSHA256 | Generates 32 chars salt. | {SSHA256}+WxTB3JxprNteeovsuSYtgI+UkVPA9lfwGoYkz3Ff7hjd1FSdmlTMkNsSExyR21KM3NvNTZ5V0p4WXJMUjFzUg==
201207
SSHA512 | Generates 32 chars salt. | {SSHA512}It+v1kAEUBbhMJYJ2swAtz+RLE6ispv/FB6G/ALhK/YWwEmrloY+0jzrWIfmu+rWUXp8u0Tg4jLXypC5oXAW00IyYnRVdEZJbE9wak96bkNRVWFCYmlJNWxrdTA0QmhL
202208
WoltLab Community Framework 2.x | Double salted bcrypt. | $2a$08$XEQDKNU/Vbootwxv5Gp7gujxFX/RUFsZLvQPYM435Dd3/p17fto02
203209
Whirlpool | | 74dfc2b27acfa364da55f93a5caee29ccad3557247eda238831b3e9bd931b01d77fe994e4f12b9d4cfa92a124461d2065197d8cf7f33fc88566da2db2a4d6eae
204210

205211
## Development
206212

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

209219
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.3.0-dev</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="16"/>
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: 2 additions & 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";
@@ -37,5 +38,6 @@ final class Opt
3738
const PASSWORD_CHANGE = "opt.password_change";
3839
const PREPEND_SALT = "opt.prepend_salt";
3940
const QUOTA_SYNC = "opt.quota_sync";
41+
const REVERSE_ACTIVE = "opt.reverse_active";
4042
const USE_CACHE = "opt.use_cache";
4143
}

lib/Crypto/AbstractAlgorithm.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ 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

7878
/**
7979
* @inheritdoc

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)