ruvents/manual-authentication-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

RUVENTS Manual Authentication Bundle

0.1.1 2017-11-22 21:52 UTC

This package is not auto-updated.

Last update: 2020-08-22 05:49:03 UTC


README

Configuration

# app/config/security.yml
security:
  firewalls:
    dev:
      pattern:  ^/(_(profiler|wdt)|css|images|js)/
      security: false

    main:
      # add manual auth to any firewall (it has no options)
      manual: ~
      anonymous: ~
      provider: user_entity_provider
      form_login:
        # ...
      logout:
        # ...
      remember_me:
        secret: "%secret%"
        always_remember_me: true

Authenticating a User in the controller

<?php

namespace AppBundle\Controller;

use Ruvents\ManualAuthenticationBundle\Security\AuthenticationList;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * @Route("/registration")
 */
class RegistrationController
{
    /**
     * @Route("")
     * @Template()
     */
    public function indexAction(AuthenticationList $authenticationList)
    {
        // registration form and etc
        
        /** @var UserInterface $user */
        
        // on form success
        
        // you have to create relevant Tokens
        // f.e. PostAuthenticationGuardToken for Guard auth
        $token = new UsernamePasswordToken($user, $user->getPassword(), 'main', $user->getRoles());
        $authenticationList->setToken('main', $token);
        
        // redirect to next page
    }
}