Преглед изворни кода

Adding commented security service provider code

Julio Montoya пре 11 година
родитељ
комит
f784ddb445
2 измењених фајлова са 20 додато и 20 уклоњено
  1. 19 19
      main/inc/services.php
  2. 1 1
      main/template/default/auth/login.tpl

+ 19 - 19
main/inc/services.php

@@ -20,13 +20,15 @@ if (is_writable($app['sys_temp_path'])) {
      *  $app['monolog']->addInfo('Testing the Monolog logging.');
      *  $app['monolog']->addError('Testing the Monolog logging.');
      */
-    $app->register(
-        new Silex\Provider\MonologServiceProvider(),
-        array(
-            'monolog.logfile' => $app['chamilo.log'],
-            'monolog.name' => 'chamilo',
-        )
-    );
+    //if ($app['debug']) {
+        $app->register(
+            new Silex\Provider\MonologServiceProvider(),
+            array(
+                'monolog.logfile' => $app['chamilo.log'],
+                'monolog.name' => 'chamilo',
+            )
+        );
+    //}
 }
 
 //Setting HttpCacheService provider in order to use do: $app['http_cache']->run();
@@ -35,8 +37,7 @@ $app->register(new Silex\Provider\HttpCacheServiceProvider(), array(
     'http_cache.cache_dir' => $app['http_cache.cache_dir'].'/',
 ));*/
 
-// Session provider
-//$app->register(new Silex\ProviderSessionServiceProvider());
+// http://symfony.com/doc/master/reference/configuration/security.html
 /*
 $app->register(new Silex\Provider\SecurityServiceProvider(), array(
     'security.firewalls' => array(
@@ -45,22 +46,21 @@ $app->register(new Silex\Provider\SecurityServiceProvider(), array(
             'anonymous' => true
         ),
         'secured' => array(
-            'http' => true,
-            'pattern' => '^/admin/.*$',
+            //'http' => true,
+            'pattern' => '^/secured',
             'form'    => array(
                 'login_path' => '/login',
-                'check_path' => '/admin/login_check',
+                'check_path' => '/secured/login_check',
+                'default_target_path' => 'admin/',
+                'username_parameter' => 'username',
+                'password_parameter' => 'password',
             ),
             'logout' => array(
-                'path' => '/logout',
+                'logout_path' => '/secured/logout',
                 'target' => '/'
             ),
             'users' => $app->share(function() use ($app) {
-                $user = new Entity\User();
-                $user->setEntityManager($app['orm.em']);
-                //$user->loadUserByUsername('admin');
-                return $user;
-
+                return $app['orm.em']->getRepository('Entity\User');
             }),
             'anonymous' => false
         ),
@@ -90,7 +90,6 @@ $app['security.encoder.digest'] = $app->share(function($app) {
 
 /*
  *
- *
 $app['security.access_manager'] = $app->share(function($app) {
     return new AccessDecisionManager($app['security.voters'], 'unanimous');
 });*/
@@ -469,6 +468,7 @@ class ChamiloServiceProvider implements ServiceProviderInterface
             return array(
                 //'root_web' => $app['root_web'],
                 'root_sys' => $app['root_sys'],
+                'sys_root' => $app['root_sys'], // just an alias
                 'sys_data_path' => $app['sys_data_path'],
                 'sys_config_path' => $app['sys_config_path'],
                 'sys_temp_path' => $app['sys_temp_path'],

+ 1 - 1
main/template/default/auth/login.tpl

@@ -1,4 +1,4 @@
-<form action="{{ url('login') }}" method="post">
+<form action="{{ url('secured_login_check') }}" method="post">
     {{ error }}
     <input type="text" name="username"  />
     <input type="password" name="password" value="" />