Skip to content

Commit

Permalink
ensure the server does not crash on misconfigured validator
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Aug 9, 2023
1 parent 8ebab29 commit 25b5edf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/auth/code/auth_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (ca *authenticator) Init(jsonconf json.RawMessage, name string) error {
}

if config.MaxRetries < 1 {
return errors.New("auth_code: invalid reties count")
return errors.New("auth_code: invalid retries count")
}

ca.name = name
Expand Down
8 changes: 7 additions & 1 deletion server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,13 @@ func (s *Session) authSecretReset(params []byte) error {
return err
}

code, _, err := store.Store.GetLogicalAuthHandler(tempScheme).GenSecret(&auth.Rec{
tempAuth := store.Store.GetLogicalAuthHandler(tempScheme)
if tempAuth == nil || !tempAuth.IsInitialized() {
logs.Err.Println("s.authSecretReset: validator with missing temp auth", credMethod, tempScheme, s.sid)
return types.ErrInternal
}

code, _, err := tempAuth.GenSecret(&auth.Rec{
Uid: uid,
AuthLevel: auth.LevelAuth,
Features: auth.FeatureNoLogin,
Expand Down

0 comments on commit 25b5edf

Please sign in to comment.