symfony 防火牆帳戶驗證(簡單的用戶機制)

security:

    # 是用明文帳號密碼的方式
    # 調取下面 memory 中的 admin/user 來登陸
    # 簡單的帳號登陸機制
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

    # https://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
    providers:
        in_memory:
            memory:
                users:
                    admin:
                        password: admin
                        roles: 'ROLE_ADMIN'
                    user:
                        password: user
                        roles: 'ROLE_USER'

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        # main:
        #     anonymous: ~

        default:
            anonymous: ~
            http_basic: ~
            # activate different ways to authenticate

            # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
            #http_basic: ~

            # https://symfony.com/doc/current/security/form_login_setup.html
            #form_login: ~
            
    access_control:
        # require ROLE_ADMIN for /admin*
        - { path: ^/admin, roles: ROLE_ADMIN }
相關文章
相關標籤/搜索