Skip to content

Commit 5478d4a

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 e409241 commit 5478d4a

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;
@@ -1084,7 +1085,22 @@ public function getSetupWizard()
10841085
*/
10851086
public function getUserBackends()
10861087
{
1087-
$this->launchConfigScript();
1088+
// TODO: Remove with v2.15
1089+
if (Fiber::getCurrent() === null) {
1090+
(new Fiber(function () {
1091+
Logger::debug(
1092+
'Running config script of module "%s" asynchronously (Process %d; Fiber %d)',
1093+
$this->getName(),
1094+
getmypid() ?: 0,
1095+
spl_object_id(Fiber::getCurrent())
1096+
);
1097+
1098+
$this->launchConfigScript();
1099+
}))->start();
1100+
} else {
1101+
$this->launchConfigScript();
1102+
}
1103+
10881104
return $this->userBackends;
10891105
}
10901106

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

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

0 commit comments

Comments
 (0)