update config

This commit is contained in:
ginuerzh
2022-01-03 23:45:49 +08:00
parent 14537d16ea
commit 566e930010
42 changed files with 412 additions and 521 deletions

View File

@ -6,22 +6,22 @@ type Authenticator interface {
}
// LocalAuthenticator is an Authenticator that authenticates client by local key-value pairs.
type LocalAuthenticator struct {
type MapAuthenticator struct {
kvs map[string]string
}
// NewLocalAuthenticator creates an Authenticator that authenticates client by local infos.
func NewLocalAuthenticator(kvs map[string]string) *LocalAuthenticator {
// NewMapAuthenticator creates an Authenticator that authenticates client by local infos.
func NewMapAuthenticator(kvs map[string]string) *MapAuthenticator {
if kvs == nil {
kvs = make(map[string]string)
}
return &LocalAuthenticator{
return &MapAuthenticator{
kvs: kvs,
}
}
// Authenticate checks the validity of the provided user-password pair.
func (au *LocalAuthenticator) Authenticate(user, password string) bool {
func (au *MapAuthenticator) Authenticate(user, password string) bool {
if au == nil {
return true
}
@ -33,8 +33,3 @@ func (au *LocalAuthenticator) Authenticate(user, password string) bool {
v, ok := au.kvs[user]
return ok && (v == "" || password == v)
}
// Add adds a key-value pair to the Authenticator.
func (au *LocalAuthenticator) Add(k, v string) {
au.kvs[k] = v
}