Skip to content

Commit

Permalink
remove unused var
Browse files Browse the repository at this point in the history
  • Loading branch information
chilagrow committed Feb 19, 2024
1 parent 5bdcfc4 commit f74532c
Show file tree
Hide file tree
Showing 44 changed files with 50 additions and 48 deletions.
9 changes: 4 additions & 5 deletions internal/handler/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ import (
"github.com/FerretDB/FerretDB/internal/util/lazyerrors"
"github.com/FerretDB/FerretDB/internal/util/must"
"github.com/FerretDB/FerretDB/internal/util/password"
"github.com/FerretDB/FerretDB/internal/wire"
)

// authenticate validates the user's credentials in the connection with the
// credentials in admin.systems.user. If EnableNewAuth is false or bypass backend auth
// is set false, it succeeds authentication and let backend handle it.
// authenticate validates users with stored credentials in admin.systems.user.
// If EnableNewAuth is false or bypass backend auth is set false, it succeeds
// authentication and let backend handle it.
//
// When admin.systems.user contains no user, the authentication is delegated to
// the backend. This may change once local exception is implemented.
func (h *Handler) authenticate(ctx context.Context, msg *wire.OpMsg) error {
func (h *Handler) authenticate(ctx context.Context) error {
if !h.EnableNewAuth {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_collmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_collstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_createindexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_createuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_currentop.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_datasize.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_dbstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_debugerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_dropallusersfromdatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_dropdatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_dropindexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_dropuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_findandmodify.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type findAndModifyResult struct {

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_getcmdlineopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_getfreemonitoringstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_getlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_getmore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_getparameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_hostinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func WriteErrorDocument(we *mongo.WriteError) *types.Document {

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_killcursors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_listcollections.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_listcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_listdatabases.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_listindexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_renamecollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
5 changes: 4 additions & 1 deletion internal/handler/msg_saslstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ func (h *Handler) MsgSASLStart(ctx context.Context, msg *wire.OpMsg) (*wire.OpMs
return nil, err
}

conninfo.Get(ctx).SetBypassBackendAuth()
if h.EnableNewAuth {
conninfo.Get(ctx).SetBypassBackendAuth()
}

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

var emptyPayload types.Binary
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_serverstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_setfreemonitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion internal/handler/msg_updateuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

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

Expand Down
Loading

0 comments on commit f74532c

Please sign in to comment.