0

i am working with an application build with Symfony3.4 using fosuserbundle and HWIOAuthBundle everything was working fine but when i tried tu use prefixes for the routing i am getting an ERR_TOO_MANY_REDIRECTS error when trying to log in

Security.yml: 
        firewalls:
        main:
            pattern: ^/
            provider: chain_provider
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager
                check_path: fos_user_security_check
                login_path:        fos_user_security_login
                failure_path:      fos_user_security_login
            oauth:
                resource_owners:
                    azure:           azure_login
                login_path:        fos_user_security_login
                failure_path:      fos_user_security_login
                use_forward:       false

                oauth_user_provider:
                    service: custom.user_provider

            logout:
                path: fos_user_security_logout
                target: fos_user_security_login
            anonymous: true
            switch_user: true
            logout_on_user_change: true

    access_control:
        - { path: ^/api/tokens, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/connect/azure, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/configuration/, role: [ROLE_SUPER_ADMIN] }
        - { path: ^/admin/, role: [ROLE_ADMIN] }
        - { path: ^/, role: IS_AUTHENTICATED_FULLY }
        - { path: ^/%app_name%, role: IS_AUTHENTICATED_FULLY }
        - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }

Routing.yml:

 fos_user_security:
       resource: "@FOSUserBundle/Resources/config/routing/security.xml"
       prefix: /%app_name%

    fos_user_resetting:
       resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
       prefix: /%app_name%/resetting
       methods:  [GET,POST]

can someone tell me what i am missing here because using fosuserbundle by itself every things works like charm but when adding the:

        oauth:
        resource_owners:
            azure:           azure_login
        login_path:        fos_user_security_login

i am going into loop

Ali Mhanna
  • 199
  • 2
  • 15

1 Answers1

0

So i found the solution for this problem my problem was not only in the security file but it seems to be that the annotation was causing the problem also but after changing the access control from :

- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

To:

- { path: ^/%app_name%/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

and in the annotation in this should not be written above the class but above the controller it self and be careful from the / at the end

Ali Mhanna
  • 199
  • 2
  • 15