Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117916021
D5872.1775408843.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D5872.1775408843.diff
View Options
diff --git a/plugins/kolab/Kolab/Configuration.php b/plugins/kolab/Kolab/Configuration.php
--- a/plugins/kolab/Kolab/Configuration.php
+++ b/plugins/kolab/Kolab/Configuration.php
@@ -7,6 +7,8 @@
*/
class Configuration extends Feature
{
+ private $done = false;
+
/**
* Feature initialization
*/
@@ -14,6 +16,7 @@
{
$this->plugin->add_hook('startup', [$this, 'startupHook']);
$this->plugin->add_hook('ready', [$this, 'readyHook']);
+ $this->plugin->add_hook('authenticate', [$this, 'authenticateHook']);
}
/**
@@ -51,15 +54,17 @@
continue 2;
case 'plugins':
foreach ($value as $plugin) {
- // Note that kolab_2fa plugin does not work when kolab_auth plugin is disabled,
- // it does not inject itself into authentication process. We may be able to fix
- // that, but since in Kolab4 we use SSO this should not be an issue.
- // The 2FA UI should still work.
- // In the future we might move this UI into Cockpit or use companion app
- // and drop the plugin completely.
-
if (!$this->rc->plugins->get_plugin($plugin)) {
- $this->rc->plugins->load_plugin($plugin);
+ $loaded = $this->rc->plugins->load_plugin($plugin);
+
+ // Depending on whether we load the kolab_2fa plugin from startup hook
+ // or other (in logon process or in settings) we might need to invoke its
+ // startup initialization code
+ if ($loaded && $plugin == 'kolab_2fa' && $this->rc->task != 'settings') {
+ /** @var \kolab_2fa $kolab_2fa */
+ $kolab_2fa = $this->rc->plugins->get_plugin($plugin);
+ $kolab_2fa->startup(['task' => $this->rc->task ?? '', 'action' => $this->rc->action ?? '']);
+ }
}
}
@@ -146,6 +151,24 @@
}
}
+ /**
+ * Authentication hook handler
+ */
+ public function authenticateHook($args): array
+ {
+ // Startup handler is not enough to properly load kolab_2fa plugin
+ // for the webmail logon page
+ if (defined('RCMAIL_START') && empty($args['abort']) && !empty($args['valid'])
+ && empty($args['sso']) && $args['user'] !== '' && $args['pass'] !== ''
+ ) {
+ $this->rc->user->data = ['username' => $args['user']];
+ $this->rc->password = $args['pass'];
+ $this->applyConfiguration($this->getConfig());
+ }
+
+ return $args;
+ }
+
/**
* Startup hook handler
*/
@@ -153,7 +176,14 @@
{
// For Kolab Syncroton we have to use the 'ready' hook.
if ($args['task'] != 'syncroton') {
- $this->applyConfiguration(Client::getMyConfig());
+ // For the 2FA logon step we have to use user credentials from the session
+ // to get the configuration and be able to enable the kolab_2fa plugin
+ if ($args['task'] == 'login' && !empty($_SESSION['kolab_2fa_factors'])) {
+ // note: password is already set in session
+ $this->rc->user->data = ['username' => $_SESSION['username']];
+ }
+
+ $this->applyConfiguration($this->getConfig());
}
return $args;
@@ -167,9 +197,22 @@
// For Kolab Syncroton we have to use the 'ready' hook. In 'startup' hook
// user is not yet authenticated.
if ($args['task'] == 'syncroton') {
- $this->applyConfiguration(Client::getMyConfig());
+ $this->applyConfiguration($this->getConfig());
}
return $args;
}
+
+ private function getConfig(): array
+ {
+ if ($this->done) {
+ return [];
+ }
+
+ $config = Client::getMyConfig();
+
+ $this->done = !empty($config);
+
+ return $config;
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 5:07 PM (1 h, 11 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833990
Default Alt Text
D5872.1775408843.diff (4 KB)
Attached To
Mode
D5872: Fix loading of kolab_2fa plugin by kolab plugin
Attached
Detach File
Event Timeline