Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@ function _addAnchor($url, $type, $vars, $url_anchor = null)
} catch (Horde_Exception $e) {
}

// IMP declares extra login params (e.g. server selector) via the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing IMP specific belongs here

// 'loginparams' auth capability. Merge these independently of the
// primary Horde auth driver.
try {
$impAuth = $injector->getInstance('Horde_Core_Factory_Auth')->create('imp');
if ($impAuth->hasCapability('loginparams')) {
$impResult = $impAuth->getLoginParams();
$loginparams = array_filter(array_merge($loginparams, $impResult['params'] ?? []));
$js_code = array_merge($js_code, $impResult['js_code'] ?? []);
$js_files = array_merge($js_files, $impResult['js_files'] ?? []);
}
} catch (\Throwable $e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching Throwable is way too broad.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like Horde_Exception|Horde\Exception\Throwable

}

/* If we currently are authenticated, and are not trying to authenticate to
* an application, redirect to initial page. This is done in index.php.
* If we are trying to authenticate to an application, but don't have to,
Expand Down
17 changes: 17 additions & 0 deletions src/Service/LoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ public function buildLoginFormData(
// No backend-specific params
}

// IMP declares extra login params (e.g. server selector) via the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing IMP specific belongs here.

// 'loginparams' auth capability. Merge these independently of the
// primary Horde auth driver, so the server list still appears when
// Horde authenticates via LDAP/etc. rather than the 'application'
// driver pointed at IMP.
try {
$impAuth = $this->injector->getInstance('Horde_Core_Factory_Auth')->create('imp');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generalize to something like:

foreach ($this->registry->listApps() as $app) {
if ($app === 'horde') continue;

try { $appAuth = $this->injector->getInstance('Horde_Core_Factory_Auth')->create($app);
if (!$appAuth->hasCapability('loginparams')) continue;
$result = $appAuth->getLoginParams();
} catch (Horde_Exception|Horde\Exception\Throwable) $e) {}

if ($impAuth->hasCapability('loginparams')) {
$impResult = $impAuth->getLoginParams();
$loginparams = array_filter(array_merge($loginparams, $impResult['params'] ?? []));
$jsCode = array_merge($jsCode, $impResult['js_code'] ?? []);
$jsFiles = array_merge($jsFiles, $impResult['js_files'] ?? []);
}
} catch (\Throwable $e) {
// IMP not installed, or no extra login params
}

// Mode selector
$modeSelector = '';
if (!empty($this->conf['user']['select_view'])) {
Expand Down