ditto
ditto copied to clipboard
Basic auth in (mqtt) connection requires you to encode the username and password twice
We upgraded from ditto 1.1.0 to 2.1.0 (big update I know) and somewhere in between the URI format for connections changed. Say you're using following configuration options:
- host: my-host
- port: 8883
- username: "username"
- password: "my password with spaces" Previously when you configured a URI you had to urlEncode the username and password: username:my%20password%20with%20spaces@my-host:8883
Right now, you have to configure the URI with double urlEncoded username and password: username:my%2520password%2520with%2520spaces@my-host:8883
thanks @thjaeckle for you support on this!
If you know this is required, you can do this but this is not documented somewhere. Besides the missing documentation this feels a bit weird and looks a bit ugly.
Hey there, I'd like to work on this, if I may. Where would I look to get started with this?
Hi @marcluque
I would start looking at org.eclipse.ditto.connectivity.service.messaging.mqtt.hivemq.AbstractHiveMqttClientFactory.configureSimpleAuth() - that's where the password is passed into the used HiveMQ MQTT client.
Maybe HiveMQ MQTT client needs the password URL encoded when there are spaces in it.
Could however also be that the password is URL decoded before it reaches this place.
Another suspicious place is org.eclipse.ditto.connectivity.model.ImmutableConnection$ConnectionUri.tryDecodeUriComponent(String) where the password is URL decoded when being read from the URI string.
So I changed our business application to double url encode all usernames and password for connections. However, I noticed this is not required for http connections... I'm going for the assumption that this is only required for mqtt connections now.
This issue should be fixed with #1407 and #1424 Can you confirm that @Yannic92 ?
Yes, passwords should now work with single encoding everywhere.