生产中的 Symfony 安全注销 404
Symfony security logout 404 in production
正如标题所说,我在 Symfony 2.8 版本的注销系统上遇到了问题。
我遵循了 documentation 并且它适用于开发环境。但是在生产中我得到了一个很棒的结果:
Not Found
The requested URL /logout was not found on this server.
这里是安全配置:
security:
role_hierarchy:
ROLE_VISITEUR: ['ROLE_TEST_VISITEUR']
ROLE_REDACTEUR: ['ROLE_VISITEUR', 'ROLE_TEST_REDACTEUR']
ROLE_VALIDATEUR_MODIFICATION: ['ROLE_VISITEUR', 'ROLE_TEST_VALIDATEUR_MODIFICATION']
ROLE_ADMIN: ['ROLE_REDACTEUR', 'ROLE_VALIDATEUR_MODIFICATION']
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
logout:
path: /logout
target: /
remember_me:
secret: '%secret%'
lifetime: 60*60*10
always_remember_me: true
guard:
authenticators:
- app.sso_authenticator
# activate different ways to authenticate
# http_basic: ~
# http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
# form_login: ~
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html
和 routing.yml:
logout:
path: /logout
我清空了 dev 和 prod 上的缓存,但没有任何反应。
debug:router 命令很好地显示了注销路由。
日志是空的,因为它是 404 错误。
感谢您的帮助。
只是好奇,我不确定这是否有效,但请尝试一下。而不是那些注销设置使用:
firewalls:
main:
...
logout: true
所以只需将其设置为 "true",看看会发生什么。
如果找到了!
问题来自 apache 2.4 中的 mod_rewrite.c,我的 vhost 一年没变了,需要使用新的完整推荐进行更新:
http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html#apache-with-mod-php-php-cgi
正如标题所说,我在 Symfony 2.8 版本的注销系统上遇到了问题。
我遵循了 documentation 并且它适用于开发环境。但是在生产中我得到了一个很棒的结果:
Not Found
The requested URL /logout was not found on this server.
这里是安全配置:
security:
role_hierarchy:
ROLE_VISITEUR: ['ROLE_TEST_VISITEUR']
ROLE_REDACTEUR: ['ROLE_VISITEUR', 'ROLE_TEST_REDACTEUR']
ROLE_VALIDATEUR_MODIFICATION: ['ROLE_VISITEUR', 'ROLE_TEST_VALIDATEUR_MODIFICATION']
ROLE_ADMIN: ['ROLE_REDACTEUR', 'ROLE_VALIDATEUR_MODIFICATION']
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
logout:
path: /logout
target: /
remember_me:
secret: '%secret%'
lifetime: 60*60*10
always_remember_me: true
guard:
authenticators:
- app.sso_authenticator
# activate different ways to authenticate
# http_basic: ~
# http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
# form_login: ~
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html
和 routing.yml:
logout:
path: /logout
我清空了 dev 和 prod 上的缓存,但没有任何反应。 debug:router 命令很好地显示了注销路由。 日志是空的,因为它是 404 错误。
感谢您的帮助。
只是好奇,我不确定这是否有效,但请尝试一下。而不是那些注销设置使用:
firewalls:
main:
...
logout: true
所以只需将其设置为 "true",看看会发生什么。
如果找到了!
问题来自 apache 2.4 中的 mod_rewrite.c,我的 vhost 一年没变了,需要使用新的完整推荐进行更新: http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html#apache-with-mod-php-php-cgi