Add basicauth and password authenticators

This commit is contained in:
Jordan Liggitt
2014-11-24 17:43:59 -05:00
parent e82b88fed8
commit 3532be3c82
9 changed files with 366 additions and 2 deletions

View File

@@ -31,11 +31,18 @@ type Token interface {
// Request attempts to extract authentication information from a request and returns
// information about the current user and true if successful, false if not successful,
// or an error if the token could not be checked.
// or an error if the request could not be checked.
type Request interface {
AuthenticateRequest(req *http.Request) (user.Info, bool, error)
}
// Password checks a username and password against a backing authentication store and
// returns information about the user and true if successful, false if not successful,
// or an error if the username and password could not be checked
type Password interface {
AuthenticatePassword(user, password string) (user.Info, bool, error)
}
// TokenFunc is a function that implements the Token interface.
type TokenFunc func(token string) (user.Info, bool, error)
@@ -51,3 +58,11 @@ type RequestFunc func(req *http.Request) (user.Info, bool, error)
func (f RequestFunc) AuthenticateRequest(req *http.Request) (user.Info, bool, error) {
return f(req)
}
// PasswordFunc is a function that implements the Password interface.
type PasswordFunc func(user, password string) (user.Info, bool, error)
// AuthenticatePassword implements authenticator.Password.
func (f PasswordFunc) AuthenticatePassword(user, password string) (user.Info, bool, error) {
return f(user, password)
}

View File

@@ -16,7 +16,7 @@ limitations under the License.
package user
// UserInfo describes a user that has been authenticated to the system.
// Info describes a user that has been authenticated to the system.
type Info interface {
// GetName returns the name that uniquely identifies this user among all
// other active users.