コード例 #1
0
ファイル: Authentication.php プロジェクト: woehrlag/Intranet
 /**
  * Initializes the configuration based on current TYPO3 mode (BE/FE) and
  * returns it afterwards.
  *
  * @return array The corresponding configuration (BE/FE)
  */
 public static function initializeConfiguration()
 {
     if (Configuration::getMode() === 'be') {
         static::$config = Configuration::getBackendConfiguration();
     } else {
         static::$config = Configuration::getFrontendConfiguration();
     }
     return static::$config;
 }
コード例 #2
0
 /**
  * Default constructor.
  *
  * @param \Causal\IgLdapSsoAuth\Domain\Model\Configuration $configuration
  * @param string $context
  */
 public function __construct(\Causal\IgLdapSsoAuth\Domain\Model\Configuration $configuration, $context)
 {
     // Load the configuration
     Configuration::initialize($context, $configuration);
     // Store current context and get related configuration
     $this->context = $context;
     $this->configuration = strtolower($context) === 'fe' ? Configuration::getFrontendConfiguration() : Configuration::getBackendConfiguration();
     // Define related tables
     if ($context === 'be') {
         $this->userTable = 'be_users';
         $this->groupTable = 'be_groups';
     } else {
         $this->userTable = 'fe_users';
         $this->groupTable = 'fe_groups';
     }
 }
コード例 #3
0
 /**
  * Returns the LDAP user groups with information merged with local TYPO3 user groups.
  *
  * @param \Causal\IgLdapSsoAuth\Domain\Model\Configuration $configuration
  * @param string $mode
  * @return array
  */
 protected function getAvailableUserGroups(\Causal\IgLdapSsoAuth\Domain\Model\Configuration $configuration, $mode)
 {
     $userGroups = array();
     $config = $mode === 'be' ? Configuration::getBackendConfiguration() : Configuration::getFrontendConfiguration();
     $ldapGroups = array();
     if (!empty($config['groups']['basedn'])) {
         $filter = Configuration::replaceFilterMarkers($config['groups']['filter']);
         $attributes = Configuration::getLdapAttributes($config['groups']['mapping']);
         $ldapGroups = Ldap::getInstance()->search($config['groups']['basedn'], $filter, $attributes);
         unset($ldapGroups['count']);
     }
     // Populate an array of TYPO3 group records corresponding to the LDAP groups
     // If a given LDAP group has no associated group in TYPO3, a fresh record
     // will be created so that $ldapGroups[i] <=> $typo3Groups[i]
     $typo3GroupPid = Configuration::getPid($config['groups']['mapping']);
     $table = $mode === 'be' ? 'be_groups' : 'fe_groups';
     $typo3Groups = Authentication::getTypo3Groups($ldapGroups, $table, $typo3GroupPid);
     foreach ($ldapGroups as $index => $ldapGroup) {
         $userGroup = Authentication::merge($ldapGroup, $typo3Groups[$index], $config['groups']['mapping']);
         // Attempt to free memory by unsetting fields which are unused in the view
         $keepKeys = array('uid', 'pid', 'deleted', 'title', 'tx_igldapssoauth_dn');
         $keys = array_keys($userGroup);
         foreach ($keys as $key) {
             if (!in_array($key, $keepKeys)) {
                 unset($userGroup[$key]);
             }
         }
         $userGroups[] = $userGroup;
     }
     return $userGroups;
 }