Skip to content

Commit

Permalink
feature #1092 allow environment variables for `remove_token_from_body…
Browse files Browse the repository at this point in the history
…_when_cookies_used` (usu)

This PR was merged into the 2.x branch.

Discussion
----------

allow environment variables for `remove_token_from_body_when_cookies_used`

#940 introduced a new config option to enable response body when cookies are used:

```yaml
remove_token_from_body_when_cookies_used: false
```

However, currently environment variables cannot be used to control this config. An error `Environment variables "bool:JWT_REMOVE_TOKEN_FROM_BODY" are never used` is thrown. After this PR, this option can also be used as following:

```yaml
remove_token_from_body_when_cookies_used: '%env(bool:JWT_REMOVE_TOKEN_FROM_BODY)%'
```

Commits
-------

376db99 allow environment variables for remove_token_from_body_when_cookies_used
  • Loading branch information
chalasr committed Dec 11, 2022
2 parents e818985 + 376db99 commit 082b4a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/LexikJWTAuthenticationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public function load(array $configs, ContainerBuilder $container)
->getDefinition('lexik_jwt_authentication.extractor.chain_extractor')
->replaceArgument(0, $tokenExtractors);

if (false === $config['remove_token_from_body_when_cookies_used']) {
if (isset($config['remove_token_from_body_when_cookies_used'])) {
$container
->getDefinition('lexik_jwt_authentication.handler.authentication_success')
->replaceArgument(3, false);
->replaceArgument(3, $config['remove_token_from_body_when_cookies_used']);
}

if ($config['set_cookies']) {
Expand Down

0 comments on commit 082b4a4

Please sign in to comment.