A
A
Alexander David2015-03-02 17:17:17
User identification
Alexander David, 2015-03-02 17:17:17

Why doesn't authorization work in prod environment (Symfony2)?

Everything works fine in `dev`, but in `prod` judging by the logs, authorization passes, then some kind of exception and redirects back to login.
logs:

[2015-03-02 15:01:48] request.INFO: Matched route "admin_auth" (parameters: "_controller": "DEV\AdminBundle\Controller\AuthController::loginAction", "_route": "admin_auth") [] []
[2015-03-02 15:01:49] request.INFO: Matched route "admin_login_check" (parameters: "_route": "admin_login_check") [] []
[2015-03-02 15:01:49] security.INFO: User "[email protected]" has been authenticated successfully [] []
[2015-03-02 15:01:49] security.DEBUG: Write SecurityContext in the session [] []
[2015-03-02 15:01:49] request.INFO: Matched route "admin_index" (parameters: "_controller": "DEV\AdminBundle\Controller\DefaultController::indexAction", "_route": "admin_index") [] []
[2015-03-02 15:01:49] security.INFO: Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.) [] []
[2015-03-02 15:01:49] security.DEBUG: Calling Authentication entry point [] []
[2015-03-02 15:01:49] security.DEBUG: Write SecurityContext in the session [] []
[2015-03-02 15:01:49] request.INFO: Matched route "admin_auth" (parameters: "_controller": "DEV\AdminBundle\Controller\AuthController::loginAction", "_route": "admin_auth") [] []

The error appears to be here:
[2015-03-02 15:01:49] security.INFO: Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.) [] []

Googled, nothing helped.
security.yml looks like this:
security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        DEV\MainBundle\Model\User:
            algorithm:        sha1
            iterations:       1
            encode_as_base64: false

    role_hierarchy:
        ROLE_ADMIN: [ROLE_ADMIN, ROLE_USER]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        user_db:
            propel:
                class: DEV\MainBundle\Model\User
                property: email

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/admin/auth$
            security: false
            anonymous: true

        admin:
            pattern:    ^/(admin|api)
            form_login:
                login_path:  admin_auth
                check_path:  admin_login_check
                default_target_path: admin_index
            provider: user_db
            logout:
                path:   admin_logout
                target: admin_auth
            switch_user: true

    access_control:
        - { path: ^/admin, roles: [ROLE_ADMIN] }

cleared the cache, the user has the role ["ROLE_ADMIN"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Centrino, 2015-03-02
@Centrino

Most likely you didn't change it to PROD somewhere in the configs (for example, access to the database).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question