diff --git a/DependencyInjection/LexikJWTAuthenticationExtension.php b/DependencyInjection/LexikJWTAuthenticationExtension.php index ba8dde6e..01f27bb3 100644 --- a/DependencyInjection/LexikJWTAuthenticationExtension.php +++ b/DependencyInjection/LexikJWTAuthenticationExtension.php @@ -52,8 +52,12 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('lexik_jwt_authentication.public_key_path', $config['public_key']); } - if (empty($config['public_key']) && empty(['secret_key'])) { - throw new InvalidConfigurationException('You must either configure a "public_key" or a "secret_key".', 'lexik_jwt_authentication'); + if (empty($config['public_key']) && empty($config['secret_key'])) { + $e = new InvalidConfigurationException('You must either configure a "public_key" or a "secret_key".'); + $e->setPath('lexik_jwt_authentication'); + + throw $e; + } $container->setParameter('lexik_jwt_authentication.pass_phrase', $config['pass_phrase']); diff --git a/Tests/DependencyInjection/LexikJWTAuthenticationExtensionTest.php b/Tests/DependencyInjection/LexikJWTAuthenticationExtensionTest.php index 26168a64..69b39da3 100644 --- a/Tests/DependencyInjection/LexikJWTAuthenticationExtensionTest.php +++ b/Tests/DependencyInjection/LexikJWTAuthenticationExtensionTest.php @@ -74,7 +74,7 @@ public function testDeprecatedDefaultEncoderService() public function testTokenExtractorsConfiguration() { // Default configuration - $chainTokenExtractor = $this->getContainer()->getDefinition('lexik_jwt_authentication.extractor.chain_extractor'); + $chainTokenExtractor = $this->getContainer(['secret_key' => 'private.pem', 'public_key' => 'public.pem'])->getDefinition('lexik_jwt_authentication.extractor.chain_extractor'); $extractorIds = array_map('strval', $chainTokenExtractor->getArgument(0)); @@ -83,7 +83,7 @@ public function testTokenExtractorsConfiguration() $this->assertNotContains('lexik_jwt_authentication.extractor.query_parameter_extractor', $extractorIds); // Custom configuration - $chainTokenExtractor = $this->getContainer(['token_extractors' => ['authorization_header' => true, 'cookie' => true]]) + $chainTokenExtractor = $this->getContainer(['secret_key' => 'private.pem', 'public_key' => 'public.pem', 'token_extractors' => ['authorization_header' => true, 'cookie' => true]]) ->getDefinition('lexik_jwt_authentication.extractor.chain_extractor'); $extractorIds = array_map('strval', $chainTokenExtractor->getArgument(0));