ruvents / manual-authentication-bundle
该包已被废弃,不再维护。没有建议的替代包。
RUVENTS 手动认证包
0.1.1
2017-11-22 21:52 UTC
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
配置
# 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
在控制器中验证用户
<?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 } }