gpt4 book ai didi

symfony - Symfony2防火墙: User has right role but “Access denied”

转载 作者:行者123 更新时间:2023-12-04 17:17:34 25 4
gpt4 key购买 nike

我无法使防火墙规则正常运行。我有一个具有D-COMPLIANCEDIALOG角色的用户和一个防火墙规则,该规则授予对该规则的访问权限:- { path: ^/ , roles: D-COMPLIANCEDIALOG }。我仍然收到拒绝访问的信息(拒绝访问,用户既不是匿名用户也不是记住我)。

#security.yml

security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
providers:
reddot:
id: reddot_user_provider

firewalls:

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

secured_area:
pattern: ^/
anonymous: ~
http_basic: ~
simple_form:
authenticator: reddot_authenticator
check_path: login_check
login_path: login

access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/ , roles: D-COMPLIANCEDIALOG }

来自symfony探查器的用户数据:
Username    admin
Authenticated? yes
Roles [D-COMPLIANCEDIALOG]
Inherited Roles { }
Token class Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken

我检查了什么:
  • Controller 没有自己的安全设置
  • 角色名称似乎没有错字
  • 这实际上是防火墙规则中的最后一行,如果删除它,则可以访问。
  • 最佳答案

    角色名称不正确。请检查Security - Roles文档

    All roles you assign to a user must begin with the ROLE_ prefix. Otherwise, they won't be handled by Symfony's security system in the normal way (i.e. unless you're doing something advanced, assigning a role like FOO to a user and then checking for FOO as described below will not work).



    当输入“不正确”的角色名称时,我也遇到了同样的问题,并且也被错误消息弄糊涂了。

    关于symfony - Symfony2防火墙: User has right role but “Access denied” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32241596/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com