Skip to content

Commit

Permalink
Fix saslContinue crashing due to not found authentication conversat…
Browse files Browse the repository at this point in the history
…ion (#4129)
  • Loading branch information
henvic committed Mar 5, 2024
1 parent 530e14e commit 0173295
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions integration/users/connection_test.go
Expand Up @@ -101,7 +101,7 @@ func TestAuthentication(t *testing.T) {
mechanisms: []string{"SCRAM-SHA-256"},
connectionMechanism: "SCRAM-SHA-256",
userNotFound: true,
errorMessage: "Authentication failed",
errorMessage: "Authentication failed.",
topologyError: true,
},
"BadPassword": {
Expand All @@ -111,7 +111,7 @@ func TestAuthentication(t *testing.T) {
connectionMechanism: "SCRAM-SHA-256",
wrongPassword: true,
topologyError: true,
errorMessage: "Authentication failed",
errorMessage: "Authentication failed.",
},
"MechanismNotSet": {
username: "user_mechanism_not_set",
Expand Down
9 changes: 8 additions & 1 deletion internal/handler/msg_saslcontinue.go
Expand Up @@ -44,11 +44,18 @@ func (h *Handler) MsgSASLContinue(ctx context.Context, msg *wire.OpMsg) (*wire.O

conv := conninfo.Get(ctx).Conv()

if conv == nil {
return nil, handlererrors.NewCommandErrorMsg(
handlererrors.ErrAuthenticationFailed,
"Authentication failed.",
)
}

response, err := conv.Step(string(payload))
if err != nil {
return nil, handlererrors.NewCommandErrorMsg(
handlererrors.ErrAuthenticationFailed,
"Authentication failed",
"Authentication failed.",
)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_saslstart.go
Expand Up @@ -245,7 +245,7 @@ func (h *Handler) scramCredentialLookup(ctx context.Context, username, dbName, m

return nil, handlererrors.NewCommandErrorMsg(
handlererrors.ErrAuthenticationFailed,
"Authentication failed",
"Authentication failed.",
)
}

Expand Down

0 comments on commit 0173295

Please sign in to comment.