Skip to content

Commit

Permalink
Fixes inability to authenticate through the older cmdQuery mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Evengard committed Feb 12, 2024
1 parent 282c8e1 commit 52764d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/handler/cmd_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"strings"

"github.com/FerretDB/FerretDB/internal/clientconn/conninfo"
"github.com/FerretDB/FerretDB/internal/handler/common"
"github.com/FerretDB/FerretDB/internal/handler/handlererrors"
"github.com/FerretDB/FerretDB/internal/types"
Expand All @@ -41,6 +42,16 @@ func (h *Handler) CmdQuery(ctx context.Context, query *wire.OpQuery) (*wire.OpRe
// database name typically is either "$external" or "admin"

if cmd == "saslStart" && strings.HasSuffix(collection, ".$cmd") {
mechanism, err := common.GetRequiredParam[string](query.Query(), "mechanism")
if err == nil && mechanism == "PLAIN" {
username, password, err := saslStartPlain(query.Query())
if err != nil {
return nil, err
}

conninfo.Get(ctx).SetAuth(username, password)
}

var emptyPayload types.Binary
reply := wire.OpReply{
NumberReturned: 1,
Expand Down

0 comments on commit 52764d3

Please sign in to comment.