/**
  * @depends testGetGroups
  */
 public function testGetUserGroups()
 {
     $test = Config::get()->securityTest;
     $userGroups = $this->principal->getUserGroups('anonymous');
     $this->assertInternalType('array', $userGroups);
     $userGroups = $this->principal->getUserGroups($test->inexistent_user);
     $this->assertInternalType('array', $userGroups);
     $userGroups = $this->principal->getUserGroups($test->existent_user);
     $this->assertInternalType('array', $userGroups);
     $this->assertNotEmpty($userGroups);
 }
Example #2
0
 public static function get()
 {
     if (is_null(static::$mediator)) {
         $class = Config::get()->registration->mediator;
         if (class_exists($class) && is_subclass_of($class, '\\Scandio\\lmvc\\modules\\registration\\handlers\\MediatorInterface')) {
             static::$mediator = new $class();
         } else {
             throw new \Exception('No valid registration mediator class configured in config.json');
         }
     }
     return static::$mediator;
 }
Example #3
0
 /**
  * @return PrincipalInterface
  * @throws \Exception
  */
 public static function get()
 {
     if (is_null(static::$principal)) {
         $class = Config::get()->security->principal;
         $userClass = null;
         if (isset(Config::get()->security->principalUser)) {
             $userClass = Config::get()->security->principalUser;
         }
         if (class_exists($class) && is_subclass_of($class, '\\Scandio\\lmvc\\modules\\security\\handlers\\PrincipalInterface')) {
             static::$principal = new $class($userClass);
         } else {
             throw new \Exception('no valid Authenticator class configured in config.json');
         }
     }
     return static::$principal;
 }
 public function getRoles()
 {
     return Config::get()->security->roles;
 }
Example #5
0
 /**
  * @return bool
  */
 public static function logout()
 {
     Session::stop();
     $logoutAction = isset(Config::get()->security->logoutAction) ? Config::get()->security->logoutAction : 'Application::index';
     return static::redirect($logoutAction);
 }
Example #6
0
 protected function getGroupUsers($groupDn)
 {
     $security = Config::get()->security;
     $search = ldap_search($this->conn, $security->user_base_dn, '(&(objectCategory=User)(memberOf=' . $groupDn . '))');
     $entries = ldap_get_entries($this->conn, $search);
     unset($entries['count']);
     $result = array();
     foreach ($entries as $entry) {
         $result[] = $entry[$security->username_attribute][0];
     }
     return $result;
 }
Example #7
0
 public static function configure($assetRootDirectory)
 {
     static::$config = array_replace_recursive(static::$_helper->asArray(json_decode(file_get_contents(dirname(dirname(__FILE__)) . '/config.json'))), static::$_helper->asArray(Config::get()->assetpipeline ?: []));
     static::$config['assetRootDirectory'] = $assetRootDirectory;
     static::initialize();
 }
Example #8
0
 /**
  * @return array[]
  */
 public function getGroups()
 {
     return Config::get()->security->groups;
 }
 /**
  * @return bool
  */
 public static function forbidden()
 {
     $forbiddenAction = isset(Config::get()->security->forbiddenAction) ? Config::get()->security->forbiddenAction : 'Security::forbidden';
     static::redirect($forbiddenAction);
     return false;
 }