From 2197ff7ee5131af8dbf3b89d8bec0202e4ed7f7a Mon Sep 17 00:00:00 2001 From: David Ansari Date: Fri, 16 Aug 2024 13:10:57 +0200 Subject: [PATCH] Use SASL layer in AMQP 1.0 Erlang client This commit ensures that AMQP 1.0 shovels will always use a SASL security layer when connecting to an AMQP 1.0 broker. Instead of skipping SASL, the client will use SASL mechanism ANONYMOUS. https://github.com/rabbitmq/rabbitmq-server/pull/11999 mandates that AMQP 1.0 clients use a SASL security layer when connecting to a RabbitMQ 4.0 node. This commit is only applied to the `v3.13.x` branch such that a shovel running on a 3.13.7 node will be able to connect via AMQP 1.0 to a RabbitMQ 4.x node. --- deps/amqp10_client/src/amqp10_client.erl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/deps/amqp10_client/src/amqp10_client.erl b/deps/amqp10_client/src/amqp10_client.erl index 303b5570bdd1..435c17a0e0b4 100644 --- a/deps/amqp10_client/src/amqp10_client.erl +++ b/deps/amqp10_client/src/amqp10_client.erl @@ -424,8 +424,8 @@ parse_result(Map) -> throw(plain_sasl_missing_userinfo); _ -> case UserInfo of - [] -> none; - undefined -> none; + [] -> anon; + undefined -> anon; U -> parse_usertoken(U) end end, @@ -452,10 +452,6 @@ parse_result(Map) -> end. -parse_usertoken(undefined) -> - none; -parse_usertoken("") -> - none; parse_usertoken(U) -> [User, Pass] = string:tokens(U, ":"), {plain, @@ -527,7 +523,7 @@ parse_uri_test_() -> [?_assertEqual({ok, #{address => "my_host", port => 9876, hostname => <<"my_host">>, - sasl => none}}, parse_uri("amqp://my_host:9876")), + sasl => anon}}, parse_uri("amqp://my_host:9876")), %% port defaults ?_assertMatch({ok, #{port := 5671}}, parse_uri("amqps://my_host")), ?_assertMatch({ok, #{port := 5672}}, parse_uri("amqp://my_host")),