/** * Hooks into \TYPO3\CMS\Core\DataHandling\DataHandler after records have been saved to the database. * * @param string $operation * @param string $table * @param mixed $id * @param array $fieldArray * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj * @return void */ public function processDatamap_afterDatabaseOperations($operation, $table, $id, array $fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler $pObj) { if ($table !== 'tx_igldapssoauth_config') { // Early return return; } if ($operation === 'new' && !is_numeric($id)) { $id = $pObj->substNEWwithIDs[$id]; } $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id); if ($row['group_membership'] == Configuration::GROUP_MEMBERSHIP_FROM_MEMBER) { $warningMessageKeys = array(); if (!empty($row['be_users_basedn']) && !empty($row['be_groups_basedn'])) { // Check backend mapping $mapping = Configuration::parseMapping($row['be_users_mapping']); if (!isset($mapping['usergroup'])) { $warningMessageKeys[] = 'tx_igldapssoauth_config.group_membership.fe.missingUsergroupMapping'; } } if (!empty($row['fe_users_basedn']) && !empty($row['fe_groups_basedn'])) { // Check frontend mapping $mapping = Configuration::parseMapping($row['fe_users_mapping']); if (!isset($mapping['usergroup'])) { $warningMessageKeys[] = 'tx_igldapssoauth_config.group_membership.be.missingUsergroupMapping'; } } foreach ($warningMessageKeys as $key) { /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->getLanguageService()->sL('LLL:EXT:ig_ldap_sso_auth/Resources/Private/Language/locallang_db.xlf:' . $key, TRUE), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } } }
/** * @test */ public function mappingWithTypoScriptIsExtended() { $mapping = <<<EOT \t\t\tname = <sn>, <givenName> \t\t\tname.wrap = | EOT; $mapping = Configuration::parseMapping($mapping); $result = Configuration::hasExtendedMapping($mapping); $this->assertTrue($result); }
/** * @test */ public function parentGroupIsNotMerged() { $mapping = <<<EOT \t\t\tpid = 1 \t\t\ttitle = <cn> \t\t\tdescription = LDAP Group <cn> \t\t\tparentGroup = <memberOf> EOT; $expected = $this->typo3GroupFixture; $expected['pid'] = '1'; $expected['title'] = 'Scientists'; $expected['description'] = 'LDAP Group Scientists'; $mapping = Configuration::parseMapping($mapping); $group = Authentication::merge($this->ldapGroupFixture, $this->typo3GroupFixture, $mapping); $this->assertEquals($expected, $group); }