diff options
Diffstat (limited to 'auth.go')
-rw-r--r-- | auth.go | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1,8 +1,12 @@ -package main +package proxy -import "time" +import ( + "errors" + "time" +) -var authIface authBackend +var authIface AuthBackend +var ErrAuthBackendExists = errors.New("auth backend already set") type user struct { name string @@ -11,7 +15,7 @@ type user struct { timestamp time.Time } -type authBackend interface { +type AuthBackend interface { Exists(name string) bool Passwd(name string) (salt, verifier []byte, err error) SetPasswd(name string, salt, verifier []byte) error @@ -19,3 +23,12 @@ type authBackend interface { Import(data []user) Export() ([]user, error) } + +func SetAuthBackend(ab AuthBackend) error { + if authIface != nil { + return ErrAuthBackendExists + } + + authIface = ab + return nil +} |