Skip to content

[feat] Add support for MQTT 5 refresh auth #1795

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

Open
robertsLando opened this issue Feb 26, 2024 Discussed in #1794 · 5 comments
Open

[feat] Add support for MQTT 5 refresh auth #1795

robertsLando opened this issue Feb 26, 2024 Discussed in #1794 · 5 comments

Comments

@robertsLando
Copy link
Member

Specs: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Re-authentication

Discussed in #1794

Originally posted by sseiber February 26, 2024
I'm using JWT Token authentication sucessfully by setting the mqtt client properties before connecting:

properties: {
    authenticationMethod: 'OAUTH2-JWT', // for Azure EventGrid
    authenticationData: <auth-token>
}

I need to be able to re-authenticate with the service when the token needs to be refreshed by sending an auth packet:

{
    cmd: 'auth',
    reasonCode: 0x19,
    properties: {
        authenticationMethod: 'OAUTH2-JWT',
        authenticationData: <auth-token>
    }
}

However, I don't see a way to send a specific packet. I'm following an example that uses MQTTnet to provide this functionality (see SendExtendedAuthenticationExchangeDataAsync):
https://github.com/dotnet/MQTTnet/blob/f82d382f23ec8388ed8a33c48b7ede08e2c18622/Source/MQTTnet/Client/MqttClient.cs#L296

Is there a method or standard pattern in mqtt.js for doing this?

@lesmoutonssauvages
Copy link

lesmoutonssauvages commented Apr 7, 2025

Hello @robertsLando , Facing the same feature needs, any news on this ?

Have you a workaround idea ?

@robertsLando
Copy link
Member Author

robertsLando commented Apr 8, 2025

You can build and send the packet manually with something like: https://github.com/mqttjs/MQTT.js/blob/main/src/lib/client.ts#L893

@robertsLando
Copy link
Member Author

If anyone is interested in this you could add a bounty for this here: https://gitpay.me

@suraj-mandal
Copy link

Hi, can I contribute to this feature as well @robertsLando?

@robertsLando
Copy link
Member Author

@suraj-mandal sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@robertsLando @suraj-mandal @lesmoutonssauvages and others