Skip to content

Commit

Permalink
do not authenticate on some handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
chilagrow committed Feb 16, 2024
1 parent 2e98e84 commit fd048c6
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 24 deletions.
4 changes: 0 additions & 4 deletions internal/handler/msg_buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import (

// MsgBuildInfo implements `buildInfo` command.
func (h *Handler) MsgBuildInfo(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
if err := h.authenticate(ctx, msg); err != nil {
return nil, err
}

aggregationStages := types.MakeArray(len(stages.Stages))
for stage := range stages.Stages {
aggregationStages.Append(stage)
Expand Down
4 changes: 0 additions & 4 deletions internal/handler/msg_connectionstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import (

// MsgConnectionStatus implements `connectionStatus` command.
func (h *Handler) MsgConnectionStatus(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
if err := h.authenticate(ctx, msg); err != nil {
return nil, err
}

users := types.MakeArray(1)

if username := conninfo.Get(ctx).Username(); username != "" {
Expand Down
4 changes: 0 additions & 4 deletions internal/handler/msg_hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import (

// MsgHello implements `hello` command.
func (h *Handler) MsgHello(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
if err := h.authenticate(ctx, msg); err != nil {
return nil, err
}

doc, err := msg.Document()
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions internal/handler/msg_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import (

// MsgPing implements `ping` command.
func (h *Handler) MsgPing(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
if err := h.authenticate(ctx, msg); err != nil {
return nil, err
}

document, err := msg.Document()
if err != nil {
return nil, lazyerrors.Error(err)
Expand Down
5 changes: 1 addition & 4 deletions internal/handler/msg_saslstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ func (h *Handler) MsgSASLStart(ctx context.Context, msg *wire.OpMsg) (*wire.OpMs
if h.EnableNewAuth {
// If new auth is enabled and the database does not contain any user,
// backend authentication is bypassed.
conninfo.Get(ctx).SetAuth(username, password)
conninfo.Get(ctx).SetBypassBackendAuth()

if err = h.authenticate(ctx, msg); err != nil {
return nil, err
}
} else {
conninfo.Get(ctx).SetAuth(username, password)
}
Expand Down
4 changes: 0 additions & 4 deletions internal/handler/msg_whatsmyuri.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import (

// MsgWhatsMyURI implements `whatsMyURI` command.
func (h *Handler) MsgWhatsMyURI(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
if err := h.authenticate(ctx, msg); err != nil {
return nil, err
}

var reply wire.OpMsg
must.NoError(reply.SetSections(wire.MakeOpMsgSection(
must.NotFail(types.NewDocument(
Expand Down

0 comments on commit fd048c6

Please sign in to comment.