Example #1
0
 /**
  * Sets a list of trusted proxies.
  *
  * You should only list the reverse proxies that you manage directly.
  *
  * @param array $proxies A list of trusted proxies
  *
  * @api
  */
 public static function setTrustedProxies(array $proxies)
 {
     return Symfony\Component\HttpFoundation\Request::setTrustedProxies($proxies);
 }
Example #2
0
define('ROLE_ADMIN', 'ROLE_ADMIN');
$app['security.role_hierarchy'] = array('ROLE_ANONYMOUS' => array(), 'ROLE_GUEST' => array('ROLE_ANONYMOUS'), 'ROLE_USER' => array('ROLE_GUEST', 'ROLE_ANONYMOUS'), 'ROLE_MODERATOR' => array('ROLE_USER', 'ROLE_GUEST', 'ROLE_ANONYMOUS'), 'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_MODERATOR', 'ROLE_GUEST', 'ROLE_ANONYMOUS'));
$app['security.access_rules'] = array(array('^/admin', 'ROLE_ADMIN'), array('^/install', 'ROLE_ADMIN'), array('^/upgrade', 'ROLE_ADMIN'), array('^/moderator', 'ROLE_MODERATOR'), array('^/profile', 'ROLE_USER'), array('^/ajax', 'ROLE_GUEST'), array('^/', $config->get('is_chat_open') ? ROLE_ANONYMOUS : ROLE_ADMIN));
$app['security.provider'] = $app->share(function () use($app) {
    return new ElfChat\Security\Authentication\Provider($app['security.role_hierarchy'], $app['security.access_rules']);
});
$app['security.middleware'] = $app->share(function () use($app) {
    return new ElfChat\Security\Authentication\SecurityMiddleware($app['security.provider'], $app['em'], $app['security.remember']);
});
$app['security.remember'] = $app->share(function () use($app) {
    return new ElfChat\Security\Authentication\Remember($app->config()->get('remember_me.token'));
});
/**
 * IP Trusted proxy
 */
Symfony\Component\HttpFoundation\Request::setTrustedProxies(array($config->get('trusted_proxy', '127.0.0.1')));
/**
 * Plugins
 */
$app['plugin_manager'] = $app->share(function () use($app) {
    return new ElfChat\Plugin\PluginManager($app->getPluginDir(), $app->getOpenDir() . '/plugins.php', $app['plugin_view_dir'], isset($app['installed_plugins']) ? $app['installed_plugins'] : array());
});
// Things to do not use then directory "open" does not writeable.
if ($app->isOpen()) {
    // Http Cache
    $app->register(new Silex\Provider\HttpCacheServiceProvider(), array('http_cache.cache_dir' => $app->getCacheDir() . '/http/'));
    // Monolog
    $app->register(new Silex\Provider\MonologServiceProvider());
    $app['monolog.name'] = 'ELFCHAT';
    $app['monolog.logfile'] = $app->getLogDir() . '/error_log.txt';
    $app['monolog.level'] = function () {