为了账号安全,请及时绑定邮箱和手机立即绑定

如何让 in_memory security.yml 提供的用户使用 Symfony4.3

如何让 in_memory security.yml 提供的用户使用 Symfony4.3

PHP
慕的地6264312 2021-10-22 12:57:23
所以我有这个新网站,我只是用 PHP/Symfony4 制作的,但是我在使身份验证登录表单与文件中in_memory提供的用户一起正常工作时遇到了麻烦security.yml。登录表单没有让我登录。我所做的我在templates/security/login.html.twig文件 HTML 表单中提供登录名和密码。我提供与存储在security.yml.发生什么了提交登录表单后,加载的下一个页面再次是登录表单,没有任何错误消息。应该发生什么我期待被重定向到/adminURL。config/packages/security.ymlsecurity:    encoders:        Symfony\Component\Security\Core\User\User: bcrypt    providers:        access_users:            memory:                users:                    steve:                        password: '$2y$13$JacnEcmt6fdm2.5mt1cKIe8h8c5nMXqxQq29J2QxiK5TDKgn0DthK'                        roles: 'ROLE_SUPER_ADMIN'    firewalls:        dev:            pattern: ^/(_(profiler|wdt)|css|images|js)/            security: false        main:            switch_user: true            provider: access_users            pattern: /admin$            form_login:                login_path: security_login                check_path: security_login                csrf_token_generator: security.csrf.token_manager    access_control:        - { path: ^/admin$, role: ROLE_SUPER_ADMIN }        - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY }src/Controller\SecurityController.php<?phpnamespace App\Controller;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;我还深入研究了,src/Security/LoginFormAuthenticator.php但在我看来,这与数据库存储的用户管理更相关。那么这甚至可以让表单登录和in_memory用户一起工作吗?我该怎么做?
查看完整描述

2 回答

?
幕布斯6054654

TA贡献1876条经验 获得超7个赞

问题是 login 和 login_check 路径。您的防火墙模式中没有。你应该有/admin/login


查看完整回答
反对 回复 2021-10-22
  • 2 回答
  • 0 关注
  • 93 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信