mariusbalcytis / gentle-force-bundle

Symfony bundle for brute-force, error and request rate limiting
MIT License
54 stars 14 forks source link

Private services in Symfony 4 #24

Open damejeras opened 4 years ago

damejeras commented 4 years ago

I think that bundle does not register properly with Symfony 4.4. I am getting this error when JS submits recaptcha response to /gentle-force/recaptcha/unlock. The controller for URI "/gentle-force/recaptcha/unlock" is not callable. Controller "maba_gentle_force.recaptcha.controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?.

As a workaround I have copied controller's code and made my own controller. Also I am using custom recaptcha template.

mehdibo commented 4 years ago

I'm having the same issue

shahariaazam commented 3 years ago

Until this library fix this, those services can be made public by Compiler Pass from your application without touching the library.

class AppKernel extends Kernel implements CompilerPassInterface
{

    // . . . . . . .
    // . . . . . . .

    public function process(ContainerBuilder $container)
    {
        $serviceIds = [
            'maba_gentle_force.recaptcha.controller',
        ];

        foreach ($serviceIds as $serviceId) {
            $container->getDefinition($serviceId)
                ->setPublic(true)
            ;
        }
    }
}