show appropriate message once browser auth is triggered

This commit is contained in:
Vladislav Yarmak 2020-05-24 18:49:35 +03:00
parent 6b024dd763
commit c2e54e8850
1 changed files with 8 additions and 1 deletions

View File

@ -82,7 +82,14 @@ func (auth *StaticAuth) Validate(wr http.ResponseWriter, req *http.Request) bool
token := hdr_parts[1] token := hdr_parts[1]
ok := (subtle.ConstantTimeCompare([]byte(token), []byte(auth.token)) == 1) ok := (subtle.ConstantTimeCompare([]byte(token), []byte(auth.token)) == 1)
if ok { if ok {
return true if auth.hiddenDomain != "" &&
(subtle.ConstantTimeCompare([]byte(req.Host), []byte(auth.hiddenDomain)) == 1 ||
subtle.ConstantTimeCompare([]byte(req.URL.Host), []byte(auth.hiddenDomain)) == 1) {
http.Error(wr, "Browser auth triggered!", http.StatusGone)
return false
} else {
return true
}
} else { } else {
requireBasicAuth(wr, req, auth.hiddenDomain) requireBasicAuth(wr, req, auth.hiddenDomain)
return false return false