diff --git a/README.md b/README.md index 97fa7fc..23dd06b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ This checks those boxes. ## Installation with Traefik +You need to have traefik forward the Path `/` to this application. + I only use docker swarm. You'd do something like the following: ```yaml diff --git a/cmd/simpleauth/main.go b/cmd/simpleauth/main.go index 12026b8..1ff9c81 100644 --- a/cmd/simpleauth/main.go +++ b/cmd/simpleauth/main.go @@ -23,17 +23,21 @@ var loginHtml []byte var successHtml []byte func rootHandler(w http.ResponseWriter, req *http.Request) { + mechanism := "unauthenticated" authenticated := false if _, passwd, _ := req.BasicAuth(); passwd == password { authenticated = true + mechanism = "HTTP-Basic" } if req.FormValue("passwd") == password { authenticated = true + mechanism = "Form" } if cookie, err := req.Cookie(CookieName); err == nil { t, _ := token.ParseString(cookie.Value) if t.Valid(secret) { authenticated = true + mechanism = "Cookie" } } @@ -42,7 +46,7 @@ func rootHandler(w http.ResponseWriter, req *http.Request) { if clientIP == "" { clientIP = req.RemoteAddr } - log.Println(clientIP, req.Method, req.URL, "authenticated:", authenticated) + log.Printf("%s %s %s [%s]", clientIP, req.Method, req.URL, mechanism) if authenticated { t := token.New(secret, time.Now().Add(lifespan)) diff --git a/static/login.html b/static/login.html index 8b40a33..2523c92 100644 --- a/static/login.html +++ b/static/login.html @@ -1,28 +1,56 @@ -
-