summaryrefslogtreecommitdiff
path: root/pkg/web/middleware.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-19 19:46:19 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-19 19:48:07 +0200
commitf5afa79d0a51b63006ee422b138f2f6aa17f7070 (patch)
treee65d730302c24cda8c73d53e143a6312a07342eb /pkg/web/middleware.go
parent12753e2c138c446fdd81809224c8cdf7f0ecea19 (diff)
[feat] passwordless-sip
Diffstat (limited to 'pkg/web/middleware.go')
-rw-r--r--pkg/web/middleware.go16
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)