|
12 | 12 |
|
13 | 13 | use Istio\Symfony\JWTAuthentication\Authenticator\UserIdentifierClaimMapping; |
14 | 14 | use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface; |
15 | | -use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; |
16 | 15 | use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
17 | 16 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
18 | 17 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument; |
|
21 | 20 | use Symfony\Component\DependencyInjection\Definition; |
22 | 21 | use Symfony\Component\DependencyInjection\Reference; |
23 | 22 |
|
24 | | -final class AuthenticatorFactory implements SecurityFactoryInterface, AuthenticatorFactoryInterface |
| 23 | +final class AuthenticatorFactory implements AuthenticatorFactoryInterface |
25 | 24 | { |
| 25 | + public const PRIORITY = -40; |
| 26 | + |
26 | 27 | public function createAuthenticator( |
27 | 28 | ContainerBuilder $container, |
28 | 29 | string $firewallName, |
29 | 30 | array $config, |
30 | 31 | string $userProviderId |
31 | | - ) { |
| 32 | + ): string|array { |
32 | 33 | $authenticator = sprintf('security.authenticator.istio_jwt_authenticator.%s', $firewallName); |
33 | 34 | $definition = new ChildDefinition('istio.jwt_authentication.authenticator'); |
34 | | - $definition->replaceArgument(0, $this->createUserIdentifierClaimMappings($container, $authenticator, $config['rules'])); |
| 35 | + $definition->replaceArgument( |
| 36 | + 0, |
| 37 | + $this->createUserIdentifierClaimMappings($container, $authenticator, $config['rules']) |
| 38 | + ); |
35 | 39 | $definition->replaceArgument(1, new Reference($userProviderId)); |
36 | 40 | $container->setDefinition($authenticator, $definition); |
37 | 41 |
|
38 | 42 | return $authenticator; |
39 | 43 | } |
40 | 44 |
|
41 | | - public function create( |
42 | | - ContainerBuilder $container, |
43 | | - string $id, |
44 | | - array $config, |
45 | | - string $userProviderId, |
46 | | - ?string $defaultEntryPointId |
47 | | - ) { |
48 | | - throw new \LogicException('Istio JWT Authentication is not supported when "security.enable_authenticator_manager" is not set to true.'); |
49 | | - } |
50 | | - |
51 | 45 | public function getPosition() |
52 | 46 | { |
53 | 47 | return 'pre_auth'; |
54 | 48 | } |
55 | 49 |
|
56 | | - public function getKey() |
| 50 | + public function getKey(): string |
57 | 51 | { |
58 | 52 | return 'istio_jwt_authenticator'; |
59 | 53 | } |
@@ -194,4 +188,9 @@ private function createPayloadExtractor( |
194 | 188 |
|
195 | 189 | return new Reference($id); |
196 | 190 | } |
| 191 | + |
| 192 | + public function getPriority(): int |
| 193 | + { |
| 194 | + return self::PRIORITY; |
| 195 | + } |
197 | 196 | } |
0 commit comments