Compare commits

..
Author SHA1 Message Date
spacefreak 959f71c0db Merge remote-tracking branch 'upstream/production/cafevdb/stable35' 2026-10-11 01:21:10 +02:00
Claus-Justus Heine d7fcc52eec Adapt for NC35 2026-09-17 14:52:32 +02:00
Claus-Justus Heine 9f679a1fad Support NC35 2026-09-17 14:35:16 +02:00
spacefreak ac9436f99a Merge remote-tracking branch 'upstream/production/cafevdb/stable33' 2026-08-15 20:13:02 +02:00
spacefreak 89a2b9c133 Merge remote-tracking branch 'upstream/production/cafevdb/stable32' 2026-08-15 20:12:28 +02:00
Claus-Justus Heine 4c3a4fe347 Claim to support NC v33 2026-03-03 13:03:20 +01:00
Claus-Justus Heine db5bfeb851 Enable group and user backends separately, based on their individual configurations.
This restores the behaviour of the app before I moved it to the
IBoostrap stuff.

Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
2025-12-05 11:22:33 +01:00
Claus-Justus Heine 601f7720cf fix(unconfigured): do not enable the backends without a complete configuration.
Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
2025-12-05 11:01:12 +01:00
Claus-Justus Heine fad85d01e0 DataQuery::connectToDatabase(), throw wenn called with empty configuration rather than producing obscure PHP errors. 2025-12-05 10:45:00 +01:00
Claus-Justus Heine 36ad938942 UserBackend, fix action recursion guard 2025-10-17 17:40:23 +02:00
Claus-Justus Heine 6d769253b8 Fix routes definitions. 2025-09-10 22:04:27 +02:00
Claus-Justus Heine ec7567acc6 Bump max NC version to 32 2025-09-05 22:18:11 +02:00
spacefreak a9f9eaf7a7 AppInfo: add config checks before using backends
Config checks were removed when moving to IBootstrap:
f6bcde7 (Move to IBootstrap initialization and remove the deprecated appinfo/app.php, 2025-04-10)

Due to the missing checks, the Nextcloud log is flooded with error messages (SQL errors) if
the configuration is incomplete. This is also if either only the user or group backend is used.
2025-07-26 21:38:51 +02:00
7 changed files with 76 additions and 64 deletions
+2 -2
View File
@@ -21,8 +21,8 @@
</types> </types>
<category>auth</category> <category>auth</category>
<dependencies> <dependencies>
<php min-version="8.0"/> <php min-version="8.4"/>
<nextcloud min-version="31" max-version="31"/> <nextcloud min-version="35" max-version="35"/>
</dependencies> </dependencies>
<settings> <settings>
<admin>\OCA\UserSQL\Settings\Admin</admin> <admin>\OCA\UserSQL\Settings\Admin</admin>
+48 -48
View File
@@ -2,8 +2,9 @@
/** /**
* Nextcloud - user_sql * Nextcloud - user_sql
* *
* @copyright 2012-2015 Andreas Böhler <dev (at) aboehler (dot) at> * @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de>
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me> * @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @copyright 2012-2015 Andreas Böhler <dev (at) aboehler (dot) at>
* @author Marcin Łojewski <dev@mlojewski.me> * @author Marcin Łojewski <dev@mlojewski.me>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@@ -22,50 +23,49 @@
use OCA\UserSQL\AppInfo\Application; use OCA\UserSQL\AppInfo\Application;
$application = new Application(); $routes = [
$application->registerRoutes( 'routes' => [
$this, [ [
"routes" => [ "name" => "settings#verifyDbConnection",
[ "url" => "/settings/db/verify",
"name" => "settings#verifyDbConnection", "verb" => "POST"
"url" => "/settings/db/verify", ],
"verb" => "POST" [
], "name" => "settings#saveProperties",
[ "url" => "/settings/properties",
"name" => "settings#saveProperties", "verb" => "POST"
"url" => "/settings/properties", ],
"verb" => "POST" [
], "name" => "settings#clearCache",
[ "url" => "/settings/cache/clear",
"name" => "settings#clearCache", "verb" => "POST"
"url" => "/settings/cache/clear", ],
"verb" => "POST" [
], "name" => "settings#tableAutocomplete",
[ "url" => "/settings/autocomplete/table",
"name" => "settings#tableAutocomplete", "verb" => "POST"
"url" => "/settings/autocomplete/table", ],
"verb" => "POST" [
], "name" => "settings#userTableAutocomplete",
[ "url" => "/settings/autocomplete/table/user",
"name" => "settings#userTableAutocomplete", "verb" => "POST"
"url" => "/settings/autocomplete/table/user", ],
"verb" => "POST" [
], "name" => "settings#userGroupTableAutocomplete",
[ "url" => "/settings/autocomplete/table/user_group",
"name" => "settings#userGroupTableAutocomplete", "verb" => "POST"
"url" => "/settings/autocomplete/table/user_group", ],
"verb" => "POST" [
], "name" => "settings#groupTableAutocomplete",
[ "url" => "/settings/autocomplete/table/group",
"name" => "settings#groupTableAutocomplete", "verb" => "POST"
"url" => "/settings/autocomplete/table/group", ],
"verb" => "POST" [
], "name" => "settings#cryptoParams",
[ "url" => "/settings/crypto/params",
"name" => "settings#cryptoParams", "verb" => "GET"
"url" => "/settings/crypto/params", ],
"verb" => "GET" ],
], ];
]
] return $routes;
);
+8 -4
View File
@@ -2,10 +2,10 @@
/** /**
* Nextcloud - user_sql * Nextcloud - user_sql
* *
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me>
* @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de> * @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de>
* @author Claus-Justus Heine <himself@claus-justus-heine.de> * @author Claus-Justus Heine <himself@claus-justus-heine.de>
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -63,8 +63,12 @@ class Application extends App implements IBootstrap
IGroupManager $groupManager, IGroupManager $groupManager,
Backend\GroupBackend $groupBackend, Backend\GroupBackend $groupBackend,
) { ) {
$userManager->registerBackend($userBackend); if ($userBackend->isConfigured()) {
$groupManager->addBackend($groupBackend); $userManager->registerBackend($userBackend);
}
if ($groupBackend->isConfigured()) {
$groupManager->addBackend($groupBackend);
}
}); });
} }
} }
+5 -5
View File
@@ -261,13 +261,13 @@ final class UserBackend extends ABackend implements
if ($user instanceof User) { if ($user instanceof User) {
$this->cache->set($cacheKey, $user); $this->cache->set($cacheKey, $user);
// avoid recursion as the action may very well call into the UserManager again ... // avoid recursion as the action may very well call into the UserManager again ...
$actions = $this->actions; $actions = $this->actions;
$this->actions = []; $this->actions = [];
foreach ($this->actions as $action) { foreach ($actions as $action) {
$action->doAction($user); $action->doAction($user);
} }
$this->actions = $actions; $this->actions = $actions;
} }
return $user; return $user;
+1 -1
View File
@@ -53,7 +53,7 @@ class Cache
*/ */
public function __construct($AppName, IConfig $config, LoggerInterface $logger) public function __construct($AppName, IConfig $config, LoggerInterface $logger)
{ {
$factory = \OC::$server->getMemCacheFactory(); $factory = \OC::$server->get(\OC\Memcache\Factory::class);
$useCache = $config->getAppValue( $useCache = $config->getAppValue(
$AppName, Opt::USE_CACHE, App::FALSE_VALUE $AppName, Opt::USE_CACHE, App::FALSE_VALUE
); );
+2 -2
View File
@@ -2,7 +2,7 @@
/** /**
* Nextcloud - user_sql * Nextcloud - user_sql
* *
* @copyright 2021 Marcin Łojewski <dev@mlojewski.me> * @copyright 2021, 2026 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me> * @author Marcin Łojewski <dev@mlojewski.me>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@@ -157,7 +157,7 @@ class SettingsController extends Controller
} }
$connectionFactory = new ConnectionFactory( $connectionFactory = new ConnectionFactory(
\OC::$server->getSystemConfig() \OC::$server->get(\OC\SystemConfig::class),
); );
$parameters = [ $parameters = [
+10 -2
View File
@@ -2,8 +2,10 @@
/** /**
* Nextcloud - user_sql * Nextcloud - user_sql
* *
* @copyright 2021 Marcin Łojewski <dev@mlojewski.me> * @copyright 2021, 2026 Marcin Łojewski <dev@mlojewski.me>
* @author Marcin Łojewski <dev@mlojewski.me> * @author Marcin Łojewski <dev@mlojewski.me>
* @copyright 2025 Claus-Justus Heine
* @author Claus-Justus Heine <himself@claus-justus-heine.de>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -21,6 +23,8 @@
namespace OCA\UserSQL\Query; namespace OCA\UserSQL\Query;
use UnexpectedValueException;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Exception as DBALException;
use OC\DB\Connection; use OC\DB\Connection;
@@ -139,7 +143,7 @@ class DataQuery
private function connectToDatabase() private function connectToDatabase()
{ {
$connectionFactory = new ConnectionFactory( $connectionFactory = new ConnectionFactory(
\OC::$server->getSystemConfig() \OC::$server->get(\OC\SystemConfig::class),
); );
$parameters = array( $parameters = array(
@@ -151,6 +155,10 @@ class DataQuery
"driverOptions" => array() "driverOptions" => array()
); );
if (empty($this->properties[DB::DRIVER])) {
throw new UnexpectedValueException('Attempt to connect without configuration.');
}
if ($this->properties[DB::DRIVER] == 'mysql') { if ($this->properties[DB::DRIVER] == 'mysql') {
if ($this->properties[DB::SSL_CA]) { if ($this->properties[DB::SSL_CA]) {
$parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA]; $parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA];