Skip to content

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

Open
@robertsLando

Description

@robertsLando

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions