From f5afa79d0a51b63006ee422b138f2f6aa17f7070 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Wed, 19 Aug 2020 19:46:19 +0200 Subject: [feat] passwordless-sip --- pkg/web/middleware.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'pkg/web') 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) -- cgit v1.2.3