mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Add basicauth and password authenticators
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user