Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Deprecation warning in_memory user with autowiring #25820

Closed
@stefantalen

Description

@stefantalen
Q A
Bug report? no
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.15

In my current application I'm getting the following deprecation warning in my logs:

Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "[email protected]" service to "Symfony\Component\Security\Core\User\UserInterface" instead.

I'm kinda confused about what I should do to fix this warning.

My security.yml looks like this:

security:
    encoders:
        My\Bundle\CompanyBundle\Entity\Contact:
            algorithm: bcrypt
        Symfony\Component\Security\Core\User\User:
            algorithm: bcrypt

    providers:
        chain_provider:
            chain:
                providers: [in_memory, contact_provider]
        in_memory:
            memory:
                users:
                    [email protected]:
                        password: "some encrypted password"
                        roles: ["ROLE_SUPER_ADMIN"]
        contact_provider:
            entity:
                class: MyCompanyBundle:Contact
                property: emailAddress

        api_user_provider:
            entity:
                class: ApiBundle:ApiUser
                property: apiKey
    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        api:
            pattern: ^/
            stateless: true
            provider: api_user_provider
            guard:
                authenticators:
                    - App\Component\Security\TokenAuthenticator
        main:
            anonymous: ~
            provider: chain_provider
            form_login:
                username_parameter:  login[username]
                password_parameter:  login[password]
                csrf_parameter: login[_token]
                login_path: login
                check_path: login
            logout:
                path:   /logout
    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

Stripping the security file to only have an in_memory provider doesn't fix the warning.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions