Search code examples
securitysymfonysymfony-security

Symfony security logout 404 in production


As the title said, i got a problem with the logout system of Symfony on version 2.8.

I followed the documentation and it work on dev environnement. But on production I got a wonderful:

Not Found

The requested URL /logout was not found on this server.

Here is the security configuration:

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

And the routing.yml:

logout:
    path: /logout

I emptied the cache on dev and prod but nothing happend. The debug:router command shows the logout route well. And the logs are empty because it's an 404 error.

Thanks for your help.


Solution

  • If found it !

    The problem came from mod_rewrite.c in apache 2.4, my vhost is the same since a year, and need to be update with the new full recommendation: http://symfony.com/doc/2.8/cookbook/configuration/web_server_configuration.html#apache-with-mod-php-php-cgi