Separate invalid key and unmatched key error
This commit is contained in:
@@ -41,10 +41,14 @@ import (
|
|||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
var (
|
var (
|
||||||
ErrSocketAuthFailed = NewError(
|
ErrSocketInvalidAuthKey = NewError(
|
||||||
http.StatusForbidden,
|
http.StatusForbidden,
|
||||||
"To use Websocket interface, a valid Auth Key must be provided")
|
"To use Websocket interface, a valid Auth Key must be provided")
|
||||||
|
|
||||||
|
ErrSocketAuthFailed = NewError(
|
||||||
|
http.StatusForbidden,
|
||||||
|
"Authentication has failed with provided Auth Key")
|
||||||
|
|
||||||
ErrSocketUnableToGenerateKey = NewError(
|
ErrSocketUnableToGenerateKey = NewError(
|
||||||
http.StatusInternalServerError,
|
http.StatusInternalServerError,
|
||||||
"Unable to generate crypto key")
|
"Unable to generate crypto key")
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ func (s socketVerification) setServerConfigRespond(
|
|||||||
func (s socketVerification) Get(
|
func (s socketVerification) Get(
|
||||||
w http.ResponseWriter, r *http.Request, l log.Logger) error {
|
w http.ResponseWriter, r *http.Request, l log.Logger) error {
|
||||||
hd := w.Header()
|
hd := w.Header()
|
||||||
|
hd.Add("Cache-Control", "no-store")
|
||||||
|
hd.Add("Pragma", "no-store")
|
||||||
|
|
||||||
key := r.Header.Get("X-Key")
|
key := r.Header.Get("X-Key")
|
||||||
|
|
||||||
@@ -110,11 +112,11 @@ func (s socketVerification) Get(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return ErrSocketAuthFailed
|
return ErrSocketInvalidAuthKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(key) > 64 {
|
if len(key) > 64 {
|
||||||
return ErrSocketAuthFailed
|
return ErrSocketInvalidAuthKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay the brute force attack. Use it with connection limits (via
|
// Delay the brute force attack. Use it with connection limits (via
|
||||||
|
|||||||
Reference in New Issue
Block a user