ruvents / manual-authentication-bundle
RUVENTS Manual Authentication Bundle
Installs: 45
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Type:symfony-bundle
Requires
- php: ^7.0
- symfony/config: ^3.0 || ^4.0
- symfony/security-bundle: ^3.0 || ^4.0
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 } }