Error security.firewalls.access_control symfony

2k Views Asked by At

Hello i have this error :

Unrecognized options "0, 1" under "security.firewalls.access_control". Available options are "access_denied_handler", "access_denied_url", "anonymous", "context", "custom_authenticators", "entry_point", "form_login", "form_login_ldap", "guard", "host", "http_basic", "http_basic_ldap", "json_login", "json_login_ldap", "lazy", "lexik_jwt", "logout", "methods", "pattern", "provider", "remember_me", "remote_user", "request_matcher", "security", "stateless", "switch_user", "user_checker", "x509".

Someone know where i need modify something for fix this error ?

For information i look in the file security.yaml:

security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        users:
            entity:
                # the class of the entity that represents users
                class: 'App\Entity\Customer'
                # property: customername
    # added by me for configure security bundle
    enable_authenticator_manager: true
    encoders:
        # use your user class name here
        App\Entity\Customer:
            # Use native password encoder
            # This value auto-selects the best possible hashing algorithm
            # (i.e. Sodium when available).
            algorithm: auto
    firewalls:
        login:
            pattern: ^/api/login
            stateless: true
            anonymous: true
            json_login:
                check_path: /api/login_check
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
        api:
            pattern: ^/api
            stateless: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator
        access_control:
            - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }
1

There are 1 best solutions below

0
On

You just have to select everything from access_control and then press shift and tab at the same time. The problem is that the security.yaml thinks access_control belongs to Firewall.

Like this:

security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
    users:
        entity:
            # the class of the entity that represents users
            class: 'App\Entity\Customer'
            # property: customername
# added by me for configure security bundle
enable_authenticator_manager: true
encoders:
    # use your user class name here
    App\Entity\Customer:
        # Use native password encoder
        # This value auto-selects the best possible hashing algorithm
        # (i.e. Sodium when available).
        algorithm: auto
firewalls:
    login:
        pattern: ^/api/login
        stateless: true
        anonymous: true
        json_login:
            check_path: /api/login_check
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
    api:
        pattern: ^/api
        stateless: true
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator
access_control:
    - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }