nelmio / NelmioSecurityBundle

Adds extra security-related features in your Symfony application
https://symfony.com/bundles/NelmioSecurityBundle/
MIT License
651 stars 85 forks source link

Can't use environment variables to enable/disable features #311

Closed janklan closed 2 years ago

janklan commented 2 years ago

The subject says it all. When I try to use an environment variable to turn something on/off, I get a following error:

Environment variables "bool:FORCE_SSL" are never used. Please, check your container's configuration.

Versions:

Working configuration:

nelmio_security:
    forced_ssl:
        enabled: true

Broken configuration:

parameters:
    env(FORCE_SSL): 'true'

nelmio_security:
    forced_ssl:
        enabled: '%env(bool:FORCE_SSL)%'

I ran following experiments:

  1. Stop declaring a default value in parameters section: didn't help
  2. Stop casting the value into boolean: the error changed to Invalid type for path "nelmio_security.forced_ssl.enabled". Expected "bool", but got "string". or whatever type did I use. Using (int) 0 is not coerced to false
  3. Try to use the environment variable in nelmio_security.referrer_policy.enabled: same result
franmomu commented 2 years ago

Hi @janklan, this doesn't seem like an issue of this bundle, have you tried to do the same in a Symfony package configuration? maybe it has to do with the nodes that can be disabled or enabled.

janklan commented 2 years ago

You're probably right. And I was probably dealing with some sort of container cache on my end. I can't reproduce it now, after playing around a little bit.

Sorry to waste your time.