Skip to content

Commit

Permalink
Allow to set provider in jwt authenticator.
Browse files Browse the repository at this point in the history
  • Loading branch information
fd6130 authored and chalasr committed Oct 24, 2021
1 parent 3f30e12 commit 5b995fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('provider')
->defaultNull()
->end()
->scalarNode('authenticator')
->defaultValue('lexik_jwt_authentication.security.jwt_authenticator')
->end()
Expand All @@ -58,6 +61,9 @@ public function addConfiguration(NodeDefinition $node)
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId)
{
$authenticatorId = 'security.authenticator.jwt.'.$firewallName;

$userProviderId = empty($config['provider']) ? $userProviderId : 'security.user.provider.concrete.' . $config['provider'];

$container
->setDefinition($authenticatorId, new ChildDefinition($config['authenticator']))
->replaceArgument(3, new Reference($userProviderId))
Expand Down
6 changes: 6 additions & 0 deletions Resources/doc/1-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ security:
api:
# ...
jwt: ~ # enables the jwt authenticator
# Full config with defaults:
# jwt:
# provider: null (you can put provider here or just ignore this config)
# authenticator: lexik_jwt_authentication.security.jwt_authenticator (default jwt authenticator)
# ...
```

For Symfony versions prior to 5.3, use the Guard authenticator:
Expand Down

0 comments on commit 5b995fb

Please sign in to comment.