From 3f4c5e2b05a825a06354a90f1afc397b56a81e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Wed, 13 Jun 2018 18:46:22 +0200 Subject: [PATCH 1/6] dev version --- CHANGELOG.md | 3 +++ appinfo/info.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e0c8f7..b5b8281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + ## [4.0.0-rc1] ### Added - New hashing algorithms: Argon2 Crypt (PHP 7.2 and above), Blowfish Crypt, Courier base64-encoded MD5, Courier base64-encoded SHA1, @@ -58,5 +60,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12 +[Unreleased]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc1...develop [4.0.0-rc1]: https://github.com/nextcloud/user_sql/compare/v3.1.0...v4.0.0-rc1 [3.1.0]: https://github.com/nextcloud/user_sql/compare/v2.4.0...v3.1.0 diff --git a/appinfo/info.xml b/appinfo/info.xml index 66b9100..0e5c94b 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -8,7 +8,7 @@ Retrieve the users and groups info. Allow the users to change their passwords. Sync the users' email addresses with the addresses stored by Nextcloud. - 4.0.0-rc1 + 4.0.0-dev agpl Andreas Böhler <dev (at) aboehler (dot) at> Marcin Łojewski <dev@mlojewski.me> From b00f61193efc3cc8340585ca70fef84a571866d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Wed, 13 Jun 2018 19:31:56 +0200 Subject: [PATCH 2/6] Fix "Use of undefined constant" error for PHP below 7.2. --- lib/Crypto/CryptArgon2.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Crypto/CryptArgon2.php b/lib/Crypto/CryptArgon2.php index a8c2d3e..14efb64 100644 --- a/lib/Crypto/CryptArgon2.php +++ b/lib/Crypto/CryptArgon2.php @@ -54,15 +54,22 @@ class CryptArgon2 extends AbstractAlgorithm * @param int $threads Number of threads to use for computing. */ public function __construct( - IL10N $localization, - $memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST, - $timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST, - $threads = PASSWORD_ARGON2_DEFAULT_THREADS + IL10N $localization, $memoryCost = -1, $timeCost = -1, $threads = -1 ) { if (version_compare(PHP_VERSION, "7.2.0") === -1) { throw new \RuntimeException( "PASSWORD_ARGON2I requires PHP 7.2.0 or above." ); + } else { + if ($memoryCost === -1) { + $memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST; + } + if ($timeCost === -1) { + $timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST; + } + if ($threads === -1) { + $threads = PASSWORD_ARGON2_DEFAULT_THREADS; + } } parent::__construct($localization); From a312ba8c4705be38b48328631ee2c0d2d3d40adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Wed, 13 Jun 2018 20:01:09 +0200 Subject: [PATCH 3/6] User active column --- CHANGELOG.md | 2 ++ README.md | 2 ++ js/settings.js | 2 +- lib/Backend/UserBackend.php | 8 ++++++++ lib/Constant/DB.php | 1 + lib/Model/User.php | 4 ++++ lib/Query/QueryProvider.php | 2 ++ templates/admin.php | 1 + 8 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5b8281..e0d1fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- User active column ## [4.0.0-rc1] ### Added diff --git a/README.md b/README.md index 2cdcfcf..287d267 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Name | Description | Details **Home** | Home path column. | Mandatory for `Query` *Home sync* option. **Password** | Password hash column. | Mandatory for user backend. **Display name** | Display name column. | Optional. +**Active** | Flag indicating if user can log in. | Optional.
Default: true. **Can change avatar** | Flag indicating if user can change its avatar. | Optional.
Default: false. #### Group table @@ -161,6 +162,7 @@ User table: jhi_users Username column: login Password column: password_hash Email column: email +Active column: activated Hashing algorithm: Unix (Crypt) ``` diff --git a/js/settings.js b/js/settings.js index 0098601..87a64d5 100644 --- a/js/settings.js +++ b/js/settings.js @@ -75,7 +75,7 @@ user_sql.adminSettingsUI = function () { ); autocomplete( - "#db-table-user-column-uid, #db-table-user-column-email, #db-table-user-column-home, #db-table-user-column-password, #db-table-user-column-name, #db-table-user-column-avatar", + "#db-table-user-column-uid, #db-table-user-column-email, #db-table-user-column-home, #db-table-user-column-password, #db-table-user-column-name, #db-table-user-column-active, #db-table-user-column-avatar", "/apps/user_sql/settings/autocomplete/table/user" ); diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php index 91e71a8..88119ee 100644 --- a/lib/Backend/UserBackend.php +++ b/lib/Backend/UserBackend.php @@ -278,6 +278,14 @@ final class UserBackend extends Backend $password, $user->password ); + if ($user->active == false) { + $this->logger->info( + "User account is inactive for user: $uid", + ["app" => $this->appName] + ); + return false; + } + if ($isCorrect !== true) { $this->logger->info( "Invalid password attempt for user: $uid", diff --git a/lib/Constant/DB.php b/lib/Constant/DB.php index 51f50f0..832cda5 100644 --- a/lib/Constant/DB.php +++ b/lib/Constant/DB.php @@ -45,6 +45,7 @@ final class DB const USER_GROUP_GID_COLUMN = "db.table.user_group.column.gid"; const USER_GROUP_UID_COLUMN = "db.table.user_group.column.uid"; + const USER_ACTIVE_COLUMN = "db.table.user.column.active"; const USER_AVATAR_COLUMN = "db.table.user.column.avatar"; const USER_EMAIL_COLUMN = "db.table.user.column.email"; const USER_HOME_COLUMN = "db.table.user.column.home"; diff --git a/lib/Model/User.php b/lib/Model/User.php index 65aed5b..90048f9 100644 --- a/lib/Model/User.php +++ b/lib/Model/User.php @@ -48,6 +48,10 @@ class User * @var string The user's home location. */ public $home; + /** + * @var bool Is user account active. + */ + public $active; /** * @var bool Can user change its avatar. */ diff --git a/lib/Query/QueryProvider.php b/lib/Query/QueryProvider.php index c1fdd52..742e784 100644 --- a/lib/Query/QueryProvider.php +++ b/lib/Query/QueryProvider.php @@ -65,6 +65,7 @@ class QueryProvider implements \ArrayAccess $gGID = $this->properties[DB::GROUP_GID_COLUMN]; $gName = $this->properties[DB::GROUP_NAME_COLUMN]; + $uActive = $this->properties[DB::USER_ACTIVE_COLUMN]; $uAvatar = $this->properties[DB::USER_AVATAR_COLUMN]; $uEmail = $this->properties[DB::USER_EMAIL_COLUMN]; $uHome = $this->properties[DB::USER_HOME_COLUMN]; @@ -90,6 +91,7 @@ class QueryProvider implements \ArrayAccess (empty($uName) ? "null" : $uName) . " AS name, " . (empty($uEmail) ? "null" : $uEmail) . " AS email, " . (empty($uHome) ? "null" : $uHome) . " AS home, " . + (empty($uActive) ? "true" : $uActive) . " AS active, " . (empty($uAvatar) ? "false" : $uAvatar) . " AS avatar"; $this->queries = [ diff --git a/templates/admin.php b/templates/admin.php index c0bc1ba..43d812e 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -147,6 +147,7 @@ function print_select_options( print_text_input($l, "db-table-user-column-home", "Home", $_['db.table.user.column.home']); print_text_input($l, "db-table-user-column-password", "Password", $_['db.table.user.column.password']); print_text_input($l, "db-table-user-column-name", "Display name", $_['db.table.user.column.name']); + print_text_input($l, "db-table-user-column-active", "Active", $_['db.table.user.column.active']); print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_['db.table.user.column.avatar']); ?> From e95241b65904e6894b74f62c9a9c3a4509e5419d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Wed, 13 Jun 2018 20:02:56 +0200 Subject: [PATCH 4/6] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0d1fa5..9cd540f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - User active column +### Changed +- Fixed "Use of undefined constant" error for Argon2 Crypt with PHP below 7.2. + ## [4.0.0-rc1] ### Added - New hashing algorithms: Argon2 Crypt (PHP 7.2 and above), Blowfish Crypt, Courier base64-encoded MD5, Courier base64-encoded SHA1, From 2757d1aea63ea0af26c280502b0e2e4d2787d929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Wed, 13 Jun 2018 20:09:07 +0200 Subject: [PATCH 5/6] Active column in sql script --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 287d267..fc64f4b 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ CREATE TABLE sql_users email TEXT NULL, home TEXT NULL, password TEXT NOT NULL, + active TINYINT(1) NOT NULL DEFAULT '1', can_change_avatar BOOLEAN NOT NULL DEFAULT FALSE, CONSTRAINT users_username_uindex UNIQUE (username) ); From 5a4d28334ad7da4e104138a544e2becd01a74de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=81ojewski?= Date: Thu, 14 Jun 2018 19:27:59 +0200 Subject: [PATCH 6/6] Tag version 4.0.0-rc2 --- CHANGELOG.md | 4 ++-- appinfo/info.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd540f..586b2b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [v4.0.0-rc2] ### Added - User active column @@ -65,6 +65,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12 -[Unreleased]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc1...develop +[v4.0.0-rc2]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc1...v4.0.0-rc2 [4.0.0-rc1]: https://github.com/nextcloud/user_sql/compare/v3.1.0...v4.0.0-rc1 [3.1.0]: https://github.com/nextcloud/user_sql/compare/v2.4.0...v3.1.0 diff --git a/appinfo/info.xml b/appinfo/info.xml index 0e5c94b..8827794 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -8,7 +8,7 @@ Retrieve the users and groups info. Allow the users to change their passwords. Sync the users' email addresses with the addresses stored by Nextcloud. - 4.0.0-dev + 4.0.0-rc2 agpl Andreas Böhler <dev (at) aboehler (dot) at> Marcin Łojewski <dev@mlojewski.me>