0

I'm playing with EasyAdminBundle and now I am trying to setup the security via form login from FOS UserBundle. However, it does not really work. Instead of being successfully logged in, I always get redirected to the "failure_path" in the security.yml. What I want:

  1. hit /easy-admin
  2. get redirected to the FOS standard login form /easy-admin/login
  3. login with my username and password (I know the credentials are ok)
  4. See the admin "index" on /easy-admin

So here is my security.yml config:

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    easy_admin:
        pattern:            ^/easy-admin
        context:            user
        form_login:
            provider:             fos_userbundle
            csrf_provider:        security.csrf.token_manager
            login_path:           fos_user_security_login
            check_path:           fos_user_security_check
            failure_path:         /
            default_target_path:  /easy-admin
        anonymous: ~

        logout:
            path:     /logout
            target:  /easy-admin/login

        access_control:  
            - { path: ^/easy-admin/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/easy-admin, role: ROLE_SUPER_ADMIN }

My routing.yml looks like this:

easy_admin_bundle:
  resource: "@EasyAdminBundle/Controller/"
  type:     annotation
  prefix:   /easy-admin

fos_user_security:
  resource: "@FOSUserBundle/Resources/config/routing/security.xml"
  prefix: /easy-admin

fos_user_profile:
  resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
  prefix: /easy-admin/profile

fos_user_register:
  resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
  prefix: /easy-admin/register

fos_user_resetting:
  resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
  prefix: /easy-admin/resetting

fos_user_change_password:
  resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
  prefix: /easy-admin/profile

So what now happens so far is: I can hit /easy-admin, I get redirected to /easy-admin/login and see the very basic login form. After providing the information and submitting the form, I get redirected to the failure route. Again: I know that the credentials I am using are correct! Any ideas what is missing or what else I can look for? For now I don't have my own AuthHandler but I thought this is not mandatory to make a basic login with session work. Thanks

Eve
  • 79
  • 1
  • 6

1 Answers1

0

so finally I found what appeared was the issue: Our cookie domain was not configured properly. After fixing this, it worked fine.

This was the final config:

  • security.yml:

    easy_admin: pattern: /easy-admin(.*) anonymous: ~ context: user

        form_login:
            login_path:         /easy-admin/login
            check_path:         /easy-admin/login_check
            default_target_path: /easy-admin/
            provider:           fos_userbundle
            use_referer:        false
    
            always_use_default_target_path: true
            require_previous_session: false
    
  • routing.yml

    easy_admin_bundle:
     resource: "@EasyAdminBundle/Controller/"
     type:     annotation
     prefix:   /easy-admin
    
    fos_user_security:
     prefix: /easy-admin
     resource: "@FOSUserBundle/Resources/config/routing/security.xml"
    
Eve
  • 79
  • 1
  • 6