remove pkgs to github.com/go-gost/x
This commit is contained in:
1 parent
6340d5198f
commit
04f6ed4708
78 files changed
+11
-5627
No files matched your search
@@ -4,25 +4,3 @@ package auth
|
||||
type Authenticator interface {
|
||||
Authenticate(user, password string) bool
|
||||
}
|
||||
|
||||
// authenticator is an Authenticator that authenticates client by key-value pairs.
|
||||
type authenticator struct {
|
||||
kvs map[string]string
|
||||
}
|
||||
|
||||
// NewAuthenticator creates an Authenticator that authenticates client by pre-defined user mapping.
|
||||
func NewAuthenticator(kvs map[string]string) Authenticator {
|
||||
return &authenticator{
|
||||
kvs: kvs,
|
||||
}
|
||||
}
|
||||
|
||||
// Authenticate checks the validity of the provided user-password pair.
|
||||
func (au *authenticator) Authenticate(user, password string) bool {
|
||||
if au == nil || len(au.kvs) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
v, ok := au.kvs[user]
|
||||
return ok && (v == "" || password == v)
|
||||
}
|
||||
Reference in new issue
Block a user