Symfony 3.4应用程序使用Guard身份验证,如何附加添加http基本身份验证?

时间:2018-08-22 07:36:07

标签: php symfony-3.4

我有一个使用Guard身份验证的Symfony 3应用程序:-

security:
    providers:
        Provider:
            id: AppBundle\Provider\CustomerProvider

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

        main:
            anonymous: ~
            logout_on_user_change: true
            stateless: false
            logout:
                path: logout
                success_handler: AppBundle\Security\LogoutHandler
            guard:
                authenticators:
                    - AppBundle\Security\FormAuthenticator
                provider: Provider


    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/.*, roles: IS_AUTHENTICATED_FULLY }

除了提供此Guard身份验证外,我还希望将整个站点都用HTTP BASIC身份验证包装,但是我无法让两个防火墙一起使用,并且在添加其他功能时似乎无法获得HTTP BASIC身份验证或无限重定向循环防火墙需要HTTP BASIC身份验证。

security:
    providers:
        in_memory:
            memory:
                users:
                    username:
                        password: password
                        roles: 'ROLE_PREVIEW'
        Provider:
            id: AppBundle\Provider\CustomerProvider

    encoders:
        Symfony\Component\Security\Core\User\User:
            algorithm: bcrypt
            cost: 15

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

        main:
            anonymous: ~
            logout_on_user_change: true
            stateless: false
            logout:
                path: logout
                success_handler: AppBundle\Security\LogoutHandler
            guard:
                authenticators:
                    - AppBundle\Security\FormAuthenticator
                provider: Provider

        everything:
            anonymous: false
            pattern: .*
            http_basic: true
            stateless: true
            form_login: false
            provider: in_memory


    access_control:
        - { path: ^/login, roles: ROLE_PREVIEW }
        - { path: ^/.*, roles: IS_AUTHENTICATED_FULLY }

如何将这两种身份验证方法一起使用?

0 个答案:

没有答案