Skip to content

Commit 5d556a1

Browse files
committed
fix(Setup/Frontend/Json): don't show auth data in anonymous call
thx @christian Pöschl of usd AG see usd-2024-0002 | Tine 2023.11.2 - Password Leakage
1 parent 29f2cd1 commit 5d556a1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

tine20/Setup/Frontend/Json.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,11 @@ public function saveEmailConfig($data)
269269

270270
/**
271271
* Returns registry data of setup
272-
* .
273-
* @see Tinebase_Application_Json_Abstract
274-
*
275-
* @return mixed array 'variable name' => 'data'
276-
*
277-
* @todo add 'titlePostfix' => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::PAGETITLEPOSTFIX, NULL, '')->value here?
272+
*
273+
* @return array
274+
* @throws Tinebase_Exception_InvalidArgument
278275
*/
279-
public function getRegistryData()
276+
public function getRegistryData(): array
280277
{
281278
// anonymous registry
282279
$registryData = array(
@@ -289,18 +286,23 @@ public function getRegistryData()
289286
// NOTE: if assetHash is not available we have a serious problem - please don't generate one!
290287
'assetHash' => Tinebase_Frontend_Http_SinglePageApplication::getAssetHash(),
291288
),
292-
'authenticationData' => $this->loadAuthenticationData(),
293289
);
294290

295-
// authenticated or non existent config
291+
// authenticated or non-existent config
296292
if (! Setup_Core::configFileExists() || Setup_Core::isRegistered(Setup_Core::USER)) {
297293
$registryData = array_merge($registryData, $this->checkConfig());
298294
$registryData = array_merge($registryData, array(
295+
'authenticationData' => Setup_Core::isRegistered(Setup_Core::USER)
296+
? $this->loadAuthenticationData() : [],
299297
'rights' => ['admin'],
300-
'acceptedTermsVersion' => (! empty($registryData['checkDB']) && $this->_controller->isInstalled('Tinebase')) ? Setup_Controller::getInstance()->getAcceptedTerms() : 0,
298+
'acceptedTermsVersion' => (! empty($registryData['checkDB']) &&
299+
$this->_controller->isInstalled(''))
300+
? Setup_Controller::getInstance()->getAcceptedTerms() : 0,
301301
'setupChecks' => $this->envCheck(),
302302
'configData' => $this->loadConfig(),
303-
'emailData' => (! empty($registryData['checkDB']) && $this->_controller->isInstalled('Tinebase')) ? $this->getEmailConfig() : array(),
303+
'emailData' => (! empty($registryData['checkDB'])
304+
&& $this->_controller->isInstalled() && Setup_Core::isRegistered(Setup_Core::USER))
305+
? $this->getEmailConfig() : array(),
304306
));
305307
}
306308

@@ -313,11 +315,11 @@ public function getRegistryData()
313315

314316
return $registryData;
315317
}
316-
318+
317319
/**
318320
* Returns registry data of all applications current user has access to
319321
* @see Tinebase_Application_Json_Abstract
320-
*
322+
*
321323
* @return mixed array 'variable name' => 'data'
322324
*
323325
* TODO DRY: most of this already is part of Tinebase_Frontend_Json::_getAnonymousRegistryData
@@ -328,7 +330,7 @@ public function getAllRegistryData()
328330
Setup_Controller::getInstance()->clearCache();
329331

330332
$registryData['Setup'] = $this->getRegistryData();
331-
333+
332334
// setup also need some core tinebase regdata
333335
$locale = Tinebase_Core::get('locale');
334336
$symbols = Zend_Locale::getTranslationList('symbols', $locale);
@@ -338,7 +340,7 @@ public function getAllRegistryData()
338340
'timeZone' => Setup_Core::getUserTimezone(),
339341
'jsonKey' => Setup_Core::get('jsonKey'),
340342
'locale' => array(
341-
'locale' => $locale->toString(),
343+
'locale' => $locale->toString(),
342344
'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale),
343345
'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale),
344346
),

0 commit comments

Comments
 (0)