Skip to content
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

Wrong Connack Reason code for Bad username or password #119

Closed
michaelg9 opened this issue Nov 28, 2019 · 3 comments · Fixed by michaelg9/hivemq-community-edition#4 or #120
Closed

Comments

@michaelg9
Copy link
Contributor

Expected behavior

When an authenticator sets that the client failed authentication with reason code BAD USERNAME OR PASSWORD, the client should receive this same code

Actual behavior

The client receives BAD_AUTHENTICATION_METHOD reason code instead

To Reproduce

Steps

Just create an extension and fail the requested connect packet with a BAD_USERNAME_OR_PASSWORD reason code and see that the client receives BAD_AUTHENTICATION_METHOD.

Buggy code

In ReasonCodeUtil.java, this extract of code:

            case BAD_USER_NAME_OR_PASSWORD:
                return Mqtt5ConnAckReasonCode.BAD_AUTHENTICATION_METHOD;
            case SERVER_UNAVAILABLE:
                return Mqtt5ConnAckReasonCode.SERVER_UNAVAILABLE;
            case SERVER_BUSY:
                return Mqtt5ConnAckReasonCode.SERVER_BUSY;
            case BANNED:
                return Mqtt5ConnAckReasonCode.BANNED;
            case BAD_AUTHENTICATION_METHOD:
                return Mqtt5ConnAckReasonCode.BAD_AUTHENTICATION_METHOD;

Obviously, the first one is wrong and should be:

            case BAD_USER_NAME_OR_PASSWORD:
                return Mqtt5ConnAckReasonCode.BAD_USER_NAME_OR_PASSWORD;

Details

  • Affected HiveMQ CE version(s): latest
  • Used JVM version: 11
@SgtSilvio
Copy link
Member

@michaelg9
Good catch 👍
If you want, you can open a PR for this.

michaelg9 added a commit to michaelg9/hivemq-community-edition that referenced this issue Nov 29, 2019
@michaelg9
Copy link
Contributor Author

Pull request here

SgtSilvio pushed a commit that referenced this issue Dec 2, 2019
@SgtSilvio
Copy link
Member

@michaelg9 Thanks again for your contribution, your PR is now merged

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