hivemq/hivemq-community-edition

Reauthorize only works once

lukasBleibt opened this issue · 4 comments

Expected behavior

A client should be able to reauthorize, if it is currently connected and authorize

Actual behavior

A reauthorize works only once. If a client has already been reauthorized in the past, it receives a 'PROTOCOL_ERROR' as a response

To Reproduce

Try to reauthorize as a connected client more than once

Details

The reauthorization worked with version 2021.2.
The described behaviour appeared first at Version 2021.3.

While looking through the code, I had the impression that the problem might be in the reauthorize implementation. If a client reauthorizes, it is checked whether the client is currently in the state 'REAUTHORIZING' or 'AUTHORIZING'. In this case the response is a 'PROTOCOL_ERROR'.
If this is not the case, the client is set to the state 'REAUTHORIZING', for the actual reauthorize process. The problem is that the client is never set to the state 'AUTHORIZED' if the reauthorize was successful. Therefore the second reauthorizing attempt fails, since the client is still in the 'REAUTHORIZING' state.

Thank you for your information @lukasBleibt,
I was able to reproduce the issue. I create a bug ticket in our internal backlog and link this issue in it, so that it gets updated as soon as the issue is resolved.
Best regards,
Daniel

I just created a PullRequest to fix the issue:
#398

@DC2-DanielKrueger
I just realize that you probably won't see my PR without a tag.

Hey @lukasBleibt I created a PR based on yours (a little change how we get the ClientConnectionContext now). Thank you for both raising the issue and providing the fix 👍