Skip to content

Commit 4caf9db

Browse files
committed
Module: Expect user and group backends upon registration
Providing a user or user group backend in configuration.php now triggers a deprecation or warning. They are expected to be announced in run.php, just like hooks. Authentication attempts during a configuration.php run, while Authentication has not been performed yet, will be also suspended now. This ensures that the current behavior, being broken or working, stays the same. refs #5265
1 parent d7188eb commit 4caf9db

2 files changed

Lines changed: 69 additions & 2 deletions

File tree

doc/80-Upgrading.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too.
55

66
## Upgrading to Icinga Web 2.14
77

8+
**Deprecations**
9+
10+
* Providing a custom user or group backend inside a module's configuration.php is deprecated and won't work as of v2.15.
11+
* It will still work as previously under the right circumstances, but will still be broken if it broke beforehand.
12+
* To keep it working as of v2.15 or make it work now, provide the custom backend inside the module's run.php instead.
13+
814
**Framework changes affecting third-party code**
915

1016
* Our JavaScript implementation to update relative times in the UI has been removed from Icinga Web, and an updated

library/Icinga/Application/Modules/Module.php

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Icinga\Application\Modules;
77

88
use Exception;
9+
use Fiber;
910
use Icinga\Application\ApplicationBootstrap;
1011
use Icinga\Application\Config;
1112
use Icinga\Application\Hook;
@@ -1085,7 +1086,22 @@ public function getSetupWizard()
10851086
*/
10861087
public function getUserBackends()
10871088
{
1088-
$this->launchConfigScript();
1089+
// TODO: Remove with v2.15
1090+
if (Fiber::getCurrent() === null) {
1091+
(new Fiber(function () {
1092+
Logger::debug(
1093+
'Running config script of module "%s" asynchronously (Process %d; Fiber %d)',
1094+
$this->getName(),
1095+
getmypid() ?: 0,
1096+
spl_object_id(Fiber::getCurrent())
1097+
);
1098+
1099+
$this->launchConfigScript();
1100+
}))->start();
1101+
} else {
1102+
$this->launchConfigScript();
1103+
}
1104+
10891105
return $this->userBackends;
10901106
}
10911107

@@ -1096,7 +1112,22 @@ public function getUserBackends()
10961112
*/
10971113
public function getUserGroupBackends()
10981114
{
1099-
$this->launchConfigScript();
1115+
// TODO: Remove with v2.15
1116+
if (Fiber::getCurrent() === null) {
1117+
(new Fiber(function () {
1118+
Logger::debug(
1119+
'Running config script of module "%s" asynchronously (Process %d; Fiber %d)',
1120+
$this->getName(),
1121+
getmypid() ?: 0,
1122+
spl_object_id(Fiber::getCurrent())
1123+
);
1124+
1125+
$this->launchConfigScript();
1126+
}))->start();
1127+
} else {
1128+
$this->launchConfigScript();
1129+
}
1130+
11001131
return $this->userGroupBackends;
11011132
}
11021133

@@ -1197,6 +1228,21 @@ protected function provideSetupWizard($className)
11971228
*/
11981229
protected function provideUserBackend($identifier, $className)
11991230
{
1231+
if ($this->registered) {
1232+
trigger_error(sprintf(
1233+
'Module "%s" already registered. Providing user backend "%s" in configuration.php'
1234+
. ' has no effect as of version 2.15. Put it in run.php instead.',
1235+
$this->getName(),
1236+
$identifier
1237+
), E_USER_DEPRECATED);
1238+
Logger::warning(
1239+
'Module "%s" already registered. Providing user backend "%s" in configuration.php'
1240+
. ' has no effect as of version 2.15. Put it in run.php instead.',
1241+
$this->getName(),
1242+
$identifier
1243+
);
1244+
}
1245+
12001246
$this->userBackends[strtolower($identifier)] = $className;
12011247
return $this;
12021248
}
@@ -1211,6 +1257,21 @@ protected function provideUserBackend($identifier, $className)
12111257
*/
12121258
protected function provideUserGroupBackend($identifier, $className)
12131259
{
1260+
if ($this->registered) {
1261+
trigger_error(sprintf(
1262+
'Module "%s" already registered. Providing user group backend "%s" in configuration.php'
1263+
. ' has no effect as of version 2.15. Put it in run.php instead.',
1264+
$this->getName(),
1265+
$identifier
1266+
), E_USER_DEPRECATED);
1267+
Logger::warning(
1268+
'Module "%s" already registered. Providing user group backend "%s" in configuration.php'
1269+
. ' has no effect as of version 2.15. Put it in run.php instead.',
1270+
$this->getName(),
1271+
$identifier
1272+
);
1273+
}
1274+
12141275
$this->userGroupBackends[strtolower($identifier)] = $className;
12151276
return $this;
12161277
}

0 commit comments

Comments
 (0)