首页 > 解决方案 > 生产服务器上的 Symfony 4.4.17 注销问题

问题描述

我对 Symfony 4.4.17 的生产有一个奇怪的问题,在本地运行良好。

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

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

安全.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 }

安全控制器.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 似乎很好,这是它的数据:

饼干内容

有任何想法吗?

标签: phpsymfonysymfony4

解决方案


非常遗憾。有人写了一个与注销路径冲突的 .htaccess 规则。谜团已揭开


推荐阅读