add chain group

This commit is contained in:
ginuerzh
2022-09-02 10:54:42 +08:00
parent e77908a89e
commit b88ab3acdc
7 changed files with 286 additions and 143 deletions

View File

@ -5,17 +5,17 @@ type Authenticator interface {
Authenticate(user, password string) bool
}
type authenticatorList struct {
type authenticatorGroup struct {
authers []Authenticator
}
func AuthenticatorList(authers ...Authenticator) Authenticator {
return &authenticatorList{
func AuthenticatorGroup(authers ...Authenticator) Authenticator {
return &authenticatorGroup{
authers: authers,
}
}
func (p *authenticatorList) Authenticate(user, password string) bool {
func (p *authenticatorGroup) Authenticate(user, password string) bool {
if len(p.authers) == 0 {
return true
}