diff options
Diffstat (limited to 'pkg/web/middleware.go')
-rw-r--r-- | pkg/web/middleware.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/pkg/web/middleware.go b/pkg/web/middleware.go index 3ff8938..21e6cd4 100644 --- a/pkg/web/middleware.go +++ b/pkg/web/middleware.go @@ -52,10 +52,18 @@ func AuthMiddleware(authenticationFunc func(*creds.Credentials) (bool, error), o return } - if c.User == "" || c.Password == "" { - log.Println("Auth request did not include user or password") - http.Error(w, "Missing user and/or password", http.StatusBadRequest) - return + if opts.PasswordPolicy == "ignore" { + if c.User == "" { + log.Println("Auth request did not include user") + http.Error(w, "Missing username", http.StatusBadRequest) + return + } + } else { + if c.User == "" || c.Password == "" { + log.Println("Auth request did not include user/password") + http.Error(w, "Missing username or password", http.StatusBadRequest) + return + } } valid, err := authenticationFunc(&c) |