Ejemplo n.º 1
0
 /**
  * Activate security using the provided Authentication Factory and User Provider
  * @param AuthenticationFactoryInterface $authFactory
  * @param UserProviderInterface $userProvider
  */
 public function activateSecurity(AuthenticationFactoryInterface $authFactory, UserProviderInterface $userProvider)
 {
     if (!$this->security) {
         $this->security = new ServiceProvider();
         $this->firewall = new Firewall('/', '/login/');
         $this->firewall->addAuthenticationFactory($authFactory, $userProvider);
         $this->security->addFirewall($this->firewall);
         $this->security->addAuthorizationVoter(new SecuredAccessVoter());
         $this->register($this->security);
         /* Auth controller */
         $this['auth.controller'] = $this->share(function () {
             return new Auth($this);
         });
         /* Add routes */
         $this->match('/login/', 'auth.controller:login')->bind('login');
     } else {
         $this->firewall->addAuthenticationFactory($authFactory, $userProvider);
     }
 }