aboutsummaryrefslogtreecommitdiff
path: root/auth.go
diff options
context:
space:
mode:
Diffstat (limited to 'auth.go')
-rw-r--r--auth.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/auth.go b/auth.go
index 2f7b0c4..3334ebf 100644
--- a/auth.go
+++ b/auth.go
@@ -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
+}