eclipse/paho.golang

Allow dynamic credentials / credentials provider

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
Currently one can only provide "static" credentials.
When one usees a MQTT broker in a SaaS way one might vant to avoid to pass "regualr" credential validation to the SaaS broker.

Describe the solution you'd like
To allow safe usage of an SaaS one could use short-lived tokens to authenticate and for authorisation.
The SaaS borker would just validate the token instead of the actual credentials.
However using "static" credentials would need to be replaced with a "CredentialsProvider" which would just be responsible to create dynamic credentials (token) or just returns the "static" ones.

Describe alternatives you've considered

Additional context
No additional context.

The ConnectPacketBuilder callback enables this scenario; it's called just before the connect packet is sent and enables the user to make whatever changes they wish (i.e. changing authentication details, adding properties etc). This approach was taken because we cannot really know all potential use-cases and want to provide maximal flexibility whilst keeping the number of options manageable (the V3 client tried to do everything and became over complicated as a result).