Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle configuration for login_method for RabbitMQ connections #723

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- 2024-03-18
* Add bundle configuration for `login_method` for RabbitMQ connections, this allow to configure other values than default AMQPLAIN (PLAIN or EXTERNAL), see https://www.rabbitmq.com/docs/access-control#mechanisms

- 2023-11-07
* Add consumer option `no_ack`

Expand Down
9 changes: 9 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OldSound\RabbitMqBundle\DependencyInjection;

use OldSound\RabbitMqBundle\RabbitMq\Producer;
use PhpAmqpLib\Connection\AMQPConnectionConfig;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
Expand Down Expand Up @@ -73,6 +74,14 @@ protected function addConnections(ArrayNodeDefinition $node)
->scalarNode('user')->defaultValue('guest')->end()
->scalarNode('password')->defaultValue('guest')->end()
->scalarNode('vhost')->defaultValue('/')->end()
->enumNode('login_method')
->values([
AMQPConnectionConfig::AUTH_AMQPPLAIN,
AMQPConnectionConfig::AUTH_PLAIN,
AMQPConnectionConfig::AUTH_EXTERNAL
])
->defaultValue(AMQPConnectionConfig::AUTH_AMQPPLAIN)
->end()
->arrayNode('hosts')
->info('connection_timeout, read_write_timeout, use_socket, ssl_context, keepalive,
heartbeat and connection_parameters_provider should be specified globally when
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ old_sound_rabbit_mq:

#requires php_sockets.dll
use_socket: true # default false

login_method: 'AMQPLAIN' # default 'AMQPLAIN', can be 'EXTERNAL' or 'PLAIN', see https://www.rabbitmq.com/docs/access-control#mechanisms

another:
# A different (unused) connection defined by an URL. One can omit all parts,
# except the scheme (amqp:). If both segment in the URL and a key value (see above)
Expand Down
5 changes: 5 additions & 0 deletions Tests/DependencyInjection/OldSoundRabbitMqExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testFooConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',

], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
Expand Down Expand Up @@ -72,6 +73,7 @@ public function testSslConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -101,6 +103,7 @@ public function testLazyConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.lazy.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -130,6 +133,7 @@ public function testDefaultConnectionDefinition()
'url' => '',
'hosts' => [],
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down Expand Up @@ -194,6 +198,7 @@ public function testClusterConnectionDefinition()
'use_socket' => false,
'url' => '',
'channel_rpc_timeout' => 0.0,
'login_method' => 'AMQPLAIN',
], $factory->getArgument(1));
$this->assertEquals('%old_sound_rabbit_mq.connection.class%', $definition->getClass());
}
Expand Down
Loading