Advertisement
vansanblch

Untitled

May 23rd, 2013
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. $app->register(
  2.     new Silex\Provider\SecurityServiceProvider(),
  3.     array(
  4.         'security.firewalls' => array(
  5.             'default' => array(
  6.                 'ldap' => true,
  7.                 'pattern' => '^/admin/',
  8.                 'form' => array(
  9.                     'login_path' => '/login',
  10.                     'check_path' => '/admin/login_check',
  11.                 ),
  12.                 'logout' => array(
  13.                     'logout_path' => '/admin/logout'
  14.                 ),
  15.                 'users' => $app->share(
  16.                     function () use ($app) {
  17.                         return new App\LdapUserProvider(
  18.                             array('ROLE_USER')
  19.                         );
  20.                     }
  21.                 ),
  22.             ),
  23.         ),
  24.     )
  25. );
  26. $app['security.authentication_listener.factory.ldap'] = $app->protect(
  27.     function ($name, $options) use ($app) {
  28.         $app['security.authentication_provider.'.$name.'.ldap'] = $app->share(
  29.             function () use ($app) {
  30.                 return new App\LdapAuthenticationProvider(
  31.                     $app['security.user_provider.default'],
  32.                     'default'
  33.                 );
  34.             }
  35.         );
  36.  
  37.         $app['security.authentication_listener.'.$name.'.ldap'] = $app->share(
  38.             function () use ($app) {
  39.                 return new App\LdapAuthenticationListener(
  40.                     $app['security'],
  41.                     $app['security.authentication_manager'],
  42.                     $app['security.http_utils']
  43.                 );
  44.             }
  45.         );
  46.  
  47.         return array(
  48.             'security.authentication_provider.'.$name.'.ldap',
  49.             'security.authentication_listener.'.$name.'.ldap',
  50.             null,
  51.             'form'
  52.         );
  53.     }
  54. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement