T
T
Tarakkolya2016-02-05 11:13:19
symfony
Tarakkolya, 2016-02-05 11:13:19

What's wrong with firewall symfony 2?

The essence of the problem is this: It is
necessary to separate the users of the organizations subdomain from the users of the main site and accordingly use the form
as described here , but the firewall organization does not work. Please tell me what am I doing wrong.

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
          ROLE_ORGANIZATION_USER: ROLE_USER
          ROLE_ORGANIZATION_ADMIN: ROLE_USER
          ROLE_ADMIN: [ROLE_USER, ROLE_ORGANIZATION_ADMIN]
          ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email
        fs.organization_user_provider:
            id: fs.organization_user_provider

    firewalls:

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

        main:
            pattern: ^/
            form_login:
                login_path: fos_user_security_login
                provider: fos_userbundle
                check_path: fos_user_security_check
                failure_path: fos_user_security_login
                default_target_path: fs_user_security_login_success
                always_use_default_target_path: true
                csrf_provider: form.csrf_provider
            logout:
                path: fos_user_security_logout
            anonymous:    true
            oauth:
                resource_owners:
                    facebook: facebook_login
                login_path: fos_user_security_login
                failure_path: fb_login_failure
                success_handler: oauth_handler
                failure_handler: oauth_handler
                oauth_user_provider:
                    service: cp.oauth_aware.user_provider.service
        organization:
            pattern: ^/
            anonymous: ~
            host: host1.%website_host%
            form_login:
                login_path: organization_login
                provider: fs.organization_user_provider
                check_path: fos_user_security_check
                failure_path: organization_login
                csrf_provider: form.csrf_provider
            logout:
                path: fos_user_security_logout


    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY}
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/profile/show/, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/profile/, roles: [ROLE_USER] }
        - { path: /admin/, role: ROLE_ADMIN }
        - { path: ^/, role: ROLE_ORGANIZATION_USER, host: host1.%website_host% }
        - { path: ^/login, role: IS_AUTHENTICATED_ANONYMOUSLY, host: host1.%website_host% }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Romanenko, 2016-02-05
@Tarakkolya

You have 2 firewalls with the same pattern. The first one always fires, as the documentation says.
Try moving the organization up

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question