gpt4 book ai didi

security - Check_path 不在 symfony 的防火墙后面,如何纠正?

转载 作者:行者123 更新时间:2023-12-01 04:08:30 26 4
gpt4 key购买 nike

我正在尝试针对 symfony2 防火墙进行身份验证,这是我的安全配置

security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
in_memory:
users:
user: { password: user, roles: [ 'ROLE_USER' ] }
admin: { password: admin, roles: [ 'ROLE_ADMIN' ]}
#main:
#entity: { class: Surgeworks\CoreBundle\Entity\User, property: username}
firewalls:
public:
pattern: .*
security: false
anonymous: true
form_login:
check_path: /{_locale}/admin/logincheck
login:
pattern: ^/{_locale}/admin/login$
security: false
anonymous: ~
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
anonymous: ~
secured_area :
provider: in_memory
pattern: ^/{_locale}/admin/.*
form_login:
check_path: /{_locale}/admin/logincheck
login_path: /{_locale}/admin/login
logout:
path : /{_locale}/admin/logout
target : /{_locale}/admin/
remember_me:
key: aSecretKey
lifetime: 3600
path: /admin/
domain: ~ # Defaults to the current domain from $_SERVER
access_control:
- { path: ^/{_locale}/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/{_locale}/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/ar/admin/logincheck, roles: ROLE_ADMIN }
- { path: ^/(ar|en|fr)/admin/, roles: ROLE_ADMIN }

这是我在 DaghoSiteBundle/Resources/config/routing.yml 中的路由:
_admin:
pattern: /admin/
defaults: { _controller: DaghoSiteBundle:Login:login , _locale : ar }
requirements:
_locale: (ar|en|fr)
login:
pattern: /admin/login
defaults : { _controller: DaghoSiteBundle:Login:login , _locale : ar }
requirements:
_locale: (ar|en|fr)
logincheck:
pattern: /admin/logincheck
#defaults: { _controller: DaghoSiteBundle:Login:logincheck , _locale: ar }
#requirements:
#_locale: (ar|en|fr)
logout:
pattern: /admin/logout

我无法通过这些设置登录,
它总是抛出异常

Unable to find the controller for path "/ar/admin/logincheck". Maybe you forgot to add the matching route in your routing configuration



即使已经设置了路线 check_path页面 >> 我将能够查看 check_path没有被重定向到登录页面..
/en/admin >> login page 
/en/logincheck >> display the logincheck template (i.e /en/logincheck isn't behind firewall )

如何修复或调试此问题,请指教

更新:
抱歉,我可能忘记写我在捆绑包前面加上了 {_locale} 前缀。像这样
在我的routing.yml
DaghoSiteBundle:
resource: "@DaghoSiteBundle/Resources/config/routing.yml"
prefix: /{_locale}
requirements:
_locale: ar|en|fr
defaults: { _locale: ar }

最佳答案

我认为您必须更改您的路线模式以包括您的 _locale范围。而不是,例如,pattern: /admin/logincheck你应该使用 pattern: {_locale}/admin/logincheck
您还可以使用控制台命令 app/console router:debug 来调试您的路由。 .

我不是 100% 确定这可以解决您的问题,但我希望它可以帮助您收集有关您的问题的更多信息。

关于security - Check_path 不在 symfony 的防火墙后面,如何纠正?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7784647/

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