|
|
|
@ -14,16 +14,24 @@ type aclCreateResponse struct {
|
|
|
|
|
ID string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ACLDisabled handles if ACL datacenter is not configured
|
|
|
|
|
func ACLDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
// checkACLDisabled will return a standard response if ACLs are disabled. This
|
|
|
|
|
// returns true if they are disabled and we should not continue.
|
|
|
|
|
func (s *HTTPServer) checkACLDisabled(resp http.ResponseWriter, req *http.Request) bool {
|
|
|
|
|
if s.agent.config.ACLDatacenter != "" {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resp.WriteHeader(http.StatusUnauthorized)
|
|
|
|
|
fmt.Fprint(resp, "ACL support disabled")
|
|
|
|
|
return nil, nil
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ACLBootstrap is used to perform a one-time ACL bootstrap operation on
|
|
|
|
|
// a cluster to get the first management token.
|
|
|
|
|
func (s *HTTPServer) ACLBootstrap(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
|
|
|
|
|
}
|
|
|
|
@ -48,6 +56,9 @@ func (s *HTTPServer) ACLBootstrap(resp http.ResponseWriter, req *http.Request) (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
|
|
|
|
|
}
|
|
|
|
@ -74,6 +85,9 @@ func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
|
|
|
|
|
}
|
|
|
|
@ -81,6 +95,9 @@ func (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
|
|
|
|
|
}
|
|
|
|
@ -129,6 +146,9 @@ func (s *HTTPServer) aclSet(resp http.ResponseWriter, req *http.Request, update
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"PUT"}}
|
|
|
|
|
}
|
|
|
|
@ -181,6 +201,9 @@ func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (inte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "GET" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
|
|
|
|
|
}
|
|
|
|
@ -215,6 +238,9 @@ func (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "GET" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
|
|
|
|
|
}
|
|
|
|
@ -241,6 +267,9 @@ func (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (inter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *HTTPServer) ACLReplicationStatus(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
|
if s.checkACLDisabled(resp, req) {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
if req.Method != "GET" {
|
|
|
|
|
return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
|
|
|
|
|
}
|
|
|
|
|