mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
agent: ACL violation returns 403 code
This commit is contained in:
parent
70eb59c63e
commit
3e4bd6a2ec
@ -2,15 +2,17 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/hashicorp/consul/consul/structs"
|
|
||||||
"github.com/mitchellh/mapstructure"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/consul/consul/structs"
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPServer is used to wrap an Agent and expose various API's
|
// HTTPServer is used to wrap an Agent and expose various API's
|
||||||
@ -148,7 +150,12 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
|
|||||||
HAS_ERR:
|
HAS_ERR:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Printf("[ERR] http: Request %v, error: %v", req.URL, err)
|
s.logger.Printf("[ERR] http: Request %v, error: %v", req.URL, err)
|
||||||
resp.WriteHeader(500)
|
code := 500
|
||||||
|
errMsg := err.Error()
|
||||||
|
if strings.Contains(errMsg, "Permission denied") || strings.Contains(errMsg, "ACL not found") {
|
||||||
|
code = 403
|
||||||
|
}
|
||||||
|
resp.WriteHeader(code)
|
||||||
resp.Write([]byte(err.Error()))
|
resp.Write([]byte(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user