Be more verbose about authentication errors
This commit is contained in:
@@ -66,16 +66,19 @@ func StatusProxy(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
header := r.Header.Get("Authorization")
|
header := r.Header.Get("Authorization")
|
||||||
if header == "" {
|
if header == "" {
|
||||||
|
common.LogError("Authorization header not found")
|
||||||
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
token_arr := strings.Split(header, " ")
|
token_arr := strings.Split(header, " ")
|
||||||
if len(token_arr) != 2 {
|
if len(token_arr) != 2 {
|
||||||
|
common.LogError("Authorization header malformed")
|
||||||
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.EqualFold(token_arr[0], "token") {
|
if !strings.EqualFold(token_arr[0], "token") {
|
||||||
|
common.LogError("Token not found in Authorization header")
|
||||||
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -83,6 +86,7 @@ func StatusProxy(w http.ResponseWriter, r *http.Request) {
|
|||||||
token := token_arr[1]
|
token := token_arr[1]
|
||||||
|
|
||||||
if !slices.Contains(config.Keys, token) {
|
if !slices.Contains(config.Keys, token) {
|
||||||
|
common.LogError("Provided token is not known")
|
||||||
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user