'How to use a variable as user name in a SF memory provider?
I was trying to use a variable provided by my .env file as the username in the memory provider in my security.yml file. My configuration looks like that:
security:
providers:
page:
memory:
users:
"%env(PAGE_USERNAME)%": { password: '%env(PAGE_PASSWORD)%' }
It was working recently but now I've got an exception every time I am using the console. Here is the exception:
[Symfony\Component\DependencyInjection\Exception\EnvParameterException]
A service name ("security.user.provider.concrete.page_%env(PAGE_USERNAME)%") cannot contain dynamic values.
After some research, it turns out that there was a modification in Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass recently which changed that behavior.
Is there another way of doing what I want to do? Is this considered as a bug?
Solution 1:[1]
For me this work perfectly ! ;)
providers:
authorized_users:
memory:
users:
"%env(HTTP_BASIC_AUTH_USERNAME)%":
password: '%env(HTTP_BASIC_AUTH_PASSWORD)%'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Newon |
