Symfony 4.4.17 生产服务器上的注销问题

问题描述

我在 Symfony 4.4.17 生产中遇到了一个奇怪的问题,在本地运行正常。

我在开发环境中使用 PHP 7.3.21,在生产环境中使用 PHP 7.3.23。

注销不起作用,prod.log 或浏览器控制台中没有错误

security.yaml

security:
  encoders:
    App\Entity\User:
      algorithm: auto

  # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
  providers:
    app_user_provider:
      entity:
        class: App\Entity\User
        property: email
  firewalls:
    dev:
      pattern: ^/(_(profiler|wdt)|css|images|js)/
      security: false
    main:
      anonymous: lazy
      guard:
        authenticators:
          - App\Security\AppAuthenticator
      logout:
        path: app_logout
        target: homepage
      remember_me:
        secret: '%kernel.secret%'
        lifetime: 604800 # 1 week in seconds
        path: /
      form_login:
        login_path: homepage
        default_target_path: profile
        use_referer: true
      json_login:
        check_path: signin_ajax

      # activate different ways to authenticate
      # https://symfony.com/doc/current/security.html#firewalls-authentication
      # https://symfony.com/doc/current/security/impersonating_user.html
      # switch_user: true

  # Easy way to control access for large sections of your site
  # Note: Only the *first* access control that matches will be used
  access_control:
    - { path: ^/admin,roles: ROLE_ADMIN }

SecurityController.PHP:

/**
 * @Route("/logout",name="app_logout",methods={"GET"})
 */
public function logoutAction()
{
    throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
}

cookie 好像没问题,这是数据:

Cookie content

有什么想法吗?

解决方法

对不起。有人写了一个与注销路径冲突的 .htaccess 规则。谜团解开