good morning!!!!

Skip to content
Snippets Groups Projects
Commit f7a42cd1 authored by or-else's avatar or-else
Browse files

crash in store due to a bug in mysql adapter on missing auth record

parent b0e2b173
Branches
Tags v0.17.10 v0.17.9
No related merge requests found
...@@ -1121,7 +1121,7 @@ func (a *adapter) AuthGetRecord(uid t.Uid, scheme string) (string, auth.Level, [ ...@@ -1121,7 +1121,7 @@ func (a *adapter) AuthGetRecord(uid t.Uid, scheme string) (string, auth.Level, [
err := a.db.Collection("auth").FindOne(a.ctx, filter, findOpts).Decode(&record) err := a.db.Collection("auth").FindOne(a.ctx, filter, findOpts).Decode(&record)
if err != nil { if err != nil {
if err == mdb.ErrNoDocuments { if err == mdb.ErrNoDocuments {
return "", 0, nil, time.Time{}, t.ErrNotFound err = t.ErrNotFound
} }
return "", 0, nil, time.Time{}, err return "", 0, nil, time.Time{}, err
} }
......
...@@ -867,8 +867,8 @@ func (a *adapter) AuthGetRecord(uid t.Uid, scheme string) (string, auth.Level, [ ...@@ -867,8 +867,8 @@ func (a *adapter) AuthGetRecord(uid t.Uid, scheme string) (string, auth.Level, [
if err := a.db.GetContext(ctx, &record, "SELECT uname,secret,expires,authlvl FROM auth WHERE userid=? AND scheme=?", if err := a.db.GetContext(ctx, &record, "SELECT uname,secret,expires,authlvl FROM auth WHERE userid=? AND scheme=?",
store.DecodeUid(uid), scheme); err != nil { store.DecodeUid(uid), scheme); err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
// Nothing found - clear the error // Nothing found - use standard error.
err = nil err = t.ErrNotFound
} }
return "", 0, nil, expires, err return "", 0, nil, expires, err
} }
......
...@@ -955,7 +955,8 @@ func (s *Session) login(msg *ClientComMessage) { ...@@ -955,7 +955,8 @@ func (s *Session) login(msg *ClientComMessage) {
} }
// authSecretReset resets an authentication secret; // authSecretReset resets an authentication secret;
// params: "auth-method-to-reset:credential-method:credential-value". // params: "auth-method-to-reset:credential-method:credential-value",
// for example: "basic:email:alice@example.com".
func (s *Session) authSecretReset(params []byte) error { func (s *Session) authSecretReset(params []byte) error {
var authScheme, credMethod, credValue string var authScheme, credMethod, credValue string
if parts := strings.Split(string(params), ":"); len(parts) == 3 { if parts := strings.Split(string(params), ":"); len(parts) == 3 {
......
...@@ -322,8 +322,13 @@ func (UsersObjMapper) GetAuthRecord(user types.Uid, scheme string) (string, auth ...@@ -322,8 +322,13 @@ func (UsersObjMapper) GetAuthRecord(user types.Uid, scheme string) (string, auth
unique, authLvl, secret, expires, err := adp.AuthGetRecord(user, scheme) unique, authLvl, secret, expires, err := adp.AuthGetRecord(user, scheme)
if err == nil { if err == nil {
parts := strings.Split(unique, ":") parts := strings.Split(unique, ":")
if len(parts) > 1 {
unique = parts[1] unique = parts[1]
} else {
err = types.ErrInternal
}
} }
return unique, authLvl, secret, expires, err return unique, authLvl, secret, expires, err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment