/** * @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); }
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; }
/** * @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; }
/** * @return bool */ public static function logout() { Session::stop(); $logoutAction = isset(Config::get()->security->logoutAction) ? Config::get()->security->logoutAction : 'Application::index'; return static::redirect($logoutAction); }
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; }
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(); }
/** * @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; }