Authentication for protocols without SASL (MQTT 3.1.1, CoAP): configurable backends, port-based SASL, or extra connection metadata #14588
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
FTR, the original discussion started in https://discord.com/channels/1092487794984755311/1092487889893466174/1419630950371033201 Pasting my answers here: I can see how it can make sense to require different authentication mechanisms for clients that connect over the public internet (e.g. where you would want to require a client certificate) vs. clients that connect from some trusted internal corporate IP address (e.g. username+password authentication is good enough). In this case we talk about different auth backends for the different client source IP addresses (or maybe for different usernames). But I still don’t see why you would want different authentication or authorisation taking place for different protocols. Surely, whether a given username connects over MQTT or AMQP or the Streams protocol from the same host, that username should be authenticated in exactly the same way? And surely if the same username publishes from the same host to a certain topic, you would want exactly the same topic authorisation to take place independent of whether that user connected over MQTT or AMQP? So, it’s important to be precise what exactly you want a different auth backend for. It would makes sense to me for different usernames or vhosts or IP addresses, but it doesn’t make sense to me for just different protocols. MQTT 5.0 supports SASL, it's just not supported (yet) in RabbitMQ. In my vision, RabbitMQ should support SASL (including the MQTT AUTH packet) for MQTT 5.0 in the future. This will streamline how authentication works in other protocols supported by RabbitMQ because SASL is already supported in AMQP 1.0, AMQP 0.9.1, and the RabbitMQ streams protocol today. Passing some additional metadata to the different auth backends, like the socket or IP address is fine to me too, if that's missing today. Note that RabbitMQ already provides the client address to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
RabbitMQ series
4.1.x
Operating system (distribution) used
Docker
How is RabbitMQ deployed?
Community Docker image
What would you like to suggest for a future version of RabbitMQ?
In short:
MQTT clients don’t use SASL — they directly call
rabbit_access_control:check_user_login
@
rabbitmq-server/deps/rabbitmq_mqtt/src/rabbit_mqtt_processor.erl
Lines 1096 to 1110 in 6ae0246
Because of this, it would be helpful if the MQTT plugin provided options for configurable authentication backends. Possible approaches include:
In detail:
In SUPER_DUPPER_APP, RabbitMQ is used as the core message bus.
So the challenge is: how to distinguish external clients from internal services?
To solve this, I created three new auth mechanisms:
SUPER_DUPPER_APP
→ plain (non-TLS and TLS, username/password)SUPER_DUPPER_APP_MTLS
→ mutual TLS, no username/passwordConfigured by port:
AMQP:
SUPER_DUPPER_APP
(plain / TLS, username+password)SUPER_DUPPER_APP_MTLS
(mTLS only)MQTT:
SUPER_DUPPER_APP
(plain, username+password)SUPER_DUPPER_APP
(TLS, username+password)SUPER_DUPPER_APP_MTLS
(mTLS only)The issue: unlike AMQP, MQTT has no SASL negotiation, so all MQTT connections go through
check_user_login/6
without a way to select the right mechanism.rabbit_access_control:check_user_login
.Proposing solution:
1.) Add a way for the MQTT plugin to have its own configurable

auth_backends
.2.) Or, as
@marchhare_54339
suggested, extendrabbit_access_control
so it receives extra connection metadata (client IP/port, server IP/port, protocol, version). Then the backend can make the right decision without per-protocol backends.3.) Provide a configuration option to associate each MQTT port with a specific SASL authentication mechanism, ensuring clients on that port use the intended auth method.

Beta Was this translation helpful? Give feedback.
All reactions