add prevalidateduser call to auth module- should be refactored

This commit is contained in:
ngerstle 2023-02-05 00:17:58 +01:00
parent 524f9c3082
commit 795a8e0399
2 changed files with 9 additions and 0 deletions

View file

@ -8,6 +8,9 @@ import (
// Auther is a generic interface to implement password-based authentication and authorization
type Auther interface {
// PreAuthenticatedUser looks up the user for a given username, and returns a user if one is found.
PreAuthenticatedUser(username) (*User, error)
// Authenticate checks username and password and returns a user if correct. The method
// returns in constant-ish time, regardless of whether the user exists or the password is
// correct or incorrect.

View file

@ -98,6 +98,12 @@ func NewSQLiteAuth(filename string, defaultRead, defaultWrite bool) (*SQLiteAuth
}, nil
}
// PreAuthenticatedUser looks up a user based on name- no validation of credentials is done!
func (a *SQLiteAuth) Authenticate(username) (*User, error) {
user, err := a.User(username)
return user, nil
}
// Authenticate checks username and password and returns a user if correct. The method
// returns in constant-ish time, regardless of whether the user exists or the password is
// correct or incorrect.