3
votes

Friends,

I need help with Symfony4. I building custom authentication system for FosUserBundle. (I need to convert it).

I base my actions on Symfony documentation

https://symfony.com/doc/4.1/security/custom_authentication_provider.html

And according to the documentation, I created all the authentic files. I will not throw them in because this is the same as in the documentation.

And I get this error:

Not configuring explicitly the provider for the "wsse" listener on "main" firewall is ambiguous as there is more than one registered provider.

This is my security.yaml

security: # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers encoders: FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]

providers:
    in_memory: { memory: ~ }
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        stateless: true
        wsse:      true
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            default_target_path: /

        logout:
            path: /logout
            target: /login
        anonymous: true

        # activate different ways to authenticate

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

        # form_login: true
        # https://symfony.com/doc/current/security/form_login_setup.html

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, role: ROLE_USER }
    - { path: ^/admin/, role: ROLE_ADMIN }

EDIT

Service Provider

App\Security\Authentication\Provider\WsseProvider:
        arguments:
            $userProviderInterface: '@fos_user.user_provider.username'
            $cachePool: '@cache.app'
        public: false

I am asking for help because I'm stuck

Thanks

1
I think you don't need wsse and you can remove it but not sure co check if you really need it symfony.com/doc/current/security/…Smaïne

1 Answers

2
votes

on your security.yml add:

providers:
    wsse:
        id: App\Security\wsseProvider #class of UserProviderInterface

firewalls:
    main:
        ...
        form_login:
            provider: wsse

on services.yaml

services:
  App\Security\wsseProvider:
    autowire: true
    public: false