diff --git a/login.php b/login.php index 67f844bf..9f81e665 100644 --- a/login.php +++ b/login.php @@ -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 +// '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) { +} + /* 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, diff --git a/src/Service/LoginService.php b/src/Service/LoginService.php index c8b1c5af..0c21e923 100644 --- a/src/Service/LoginService.php +++ b/src/Service/LoginService.php @@ -114,6 +114,23 @@ public function buildLoginFormData( // No backend-specific params } + // IMP declares extra login params (e.g. server selector) via the + // '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'); + 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'])) {