diff --git a/pkg/login-validator/cmd/auth_fwd.go b/pkg/login-validator/cmd/auth_fwd.go index 1a62088..0ba0331 100644 --- a/pkg/login-validator/cmd/auth_fwd.go +++ b/pkg/login-validator/cmd/auth_fwd.go @@ -1,6 +1,8 @@ package main import ( + "bytes" + "encoding/json" "net/http" "net/url" ) @@ -9,18 +11,23 @@ type FWDAuth struct { URI *url.URL } +type loginForm struct { + Username string + Password string +} + func (f FWDAuth) checkAuth(username, password string) (res bool, err error) { - if r, err := http.NewRequest("GET", f.URI.String(), nil); err != nil { + lf := loginForm{username, password} + j, err := json.Marshal(lf) + if err != nil { + return false, err + } else if r, err := http.NewRequest("POST", f.URI.String(), bytes.NewReader(j)); err != nil { + return false, err + } else if resp, err := http.DefaultClient.Do(r); err != nil { return false, err } else { - r.SetBasicAuth(username, password) + resp.Body.Close() - if resp, err := http.DefaultClient.Do(r); err != nil { - return false, err - } else { - resp.Body.Close() - - return resp.StatusCode < 400, err - } + return resp.StatusCode < 400, err } }