0

I'm wanting to put a secret pass_phrase value (0000) into .env.dev.local file (for lexik_jwt_authentication), but the authentication wasn't working.

If I put the value directly into the file config/packages/lexik_jwt_authentication.yaml, authentication works.

# composer.json
"symfony/dotenv": "^4.2",

# config/packages/lexik_jwt_authentication.yaml
lexik_jwt_authentication:
    pass_phrase: '%env(JWT_PASSPHRASE)%'


# .env.dev.local
JWT_PASSPHRASE='0000'

# .env
JWT_PASSPHRASE=''

To debug this, I edited vendor/lexik/jwt-authentication-bundle/DependencyInjection/LexikJWTAuthenticationExtension.php as follows to see what's going on:

# vendor/lexik/jwt-authentication-bundle/DependencyInjection/LexikJWTAuthenticationExtension.php
var_dump($config['pass_phrase']);                                                                                                                   
die('end of the story');                                                                                                                            

$container->setParameter('lexik_jwt_authentication.pass_phrase', $config['pass_phrase']); 

The shown value is :

env_6a2d2290a3aa88de_resolve_JWT_PASSPHRASE_15ef1bcee0c9b69d171abe271c686aa8

The documentation https://symfony.com/doc/master/configuration/environment_variables.html is clear and pretty easy about this, first defining a value into the dot envs (DATABASE_URL), then using it into the config files '%env(DATABASE_URL)%'.

How do I fix this and why I'm having this value?

miken32
  • 42,008
  • 16
  • 111
  • 154
smarber
  • 4,829
  • 7
  • 37
  • 78
  • I believe there's a certain order to things. configuration from .env files will always be lower in priority than env vars given by php (maybe given by the webserver) – Jakumi Apr 08 '19 at 18:25
  • @Jakumi I do not have any, I'm pretty sure. I'm running `symfony server:start` – smarber Apr 08 '19 at 19:10
  • I believe `symfony about` should give you some information. that is ... the source of your configuration. oh, and also there is the parameters. you can have lines like `env(JWT_PASSPHRASE): somevalue`. – Jakumi Apr 08 '19 at 19:11
  • @Jakumi `Command "about" does not exist.`. `you can have lines like env(JWT_PASSPHRASE): somevalue` No I have just re checked :/ – smarber Apr 08 '19 at 19:32
  • I believe `bin/console about` should work ... at least it's working for all of my installations. don't know though, if the passphrase is in there. also, if the pass phrase you provide isn't valid (whatever that may mean), maybe it's replaced by something valid? – Jakumi Apr 08 '19 at 19:42

0 Answers0