agent: Special handler if ACL support is disabled

pull/291/head
Armon Dadgar 2014-08-12 11:34:58 -07:00
parent 2d5e869e69
commit fee3524dea
2 changed files with 22 additions and 6 deletions

View File

@ -12,6 +12,13 @@ type aclCreateResponse struct {
ID string ID string
} }
// aclDisabled handles if ACL datacenter is not configured
func aclDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
resp.WriteHeader(401)
resp.Write([]byte("ACL support disabled"))
return nil, nil
}
func (s *HTTPServer) ACLDelete(resp http.ResponseWriter, req *http.Request) (interface{}, error) { func (s *HTTPServer) ACLDelete(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
args := structs.ACLRequest{ args := structs.ACLRequest{
Op: structs.ACLDelete, Op: structs.ACLDelete,

View File

@ -99,12 +99,21 @@ func (s *HTTPServer) registerHandlers(enableDebug bool) {
s.mux.HandleFunc("/v1/session/node/", s.wrap(s.SessionsForNode)) s.mux.HandleFunc("/v1/session/node/", s.wrap(s.SessionsForNode))
s.mux.HandleFunc("/v1/session/list", s.wrap(s.SessionList)) s.mux.HandleFunc("/v1/session/list", s.wrap(s.SessionList))
s.mux.HandleFunc("/v1/acl/create", s.wrap(s.ACLCreate)) if s.agent.config.ACLDatacenter != "" {
s.mux.HandleFunc("/v1/acl/update", s.wrap(s.ACLUpdate)) s.mux.HandleFunc("/v1/acl/create", s.wrap(s.ACLCreate))
s.mux.HandleFunc("/v1/acl/delete/", s.wrap(s.ACLDelete)) s.mux.HandleFunc("/v1/acl/update", s.wrap(s.ACLUpdate))
s.mux.HandleFunc("/v1/acl/info/", s.wrap(s.ACLGet)) s.mux.HandleFunc("/v1/acl/delete/", s.wrap(s.ACLDelete))
s.mux.HandleFunc("/v1/acl/clone/", s.wrap(s.ACLClone)) s.mux.HandleFunc("/v1/acl/info/", s.wrap(s.ACLGet))
s.mux.HandleFunc("/v1/acl/list", s.wrap(s.ACLList)) s.mux.HandleFunc("/v1/acl/clone/", s.wrap(s.ACLClone))
s.mux.HandleFunc("/v1/acl/list", s.wrap(s.ACLList))
} else {
s.mux.HandleFunc("/v1/acl/create", s.wrap(aclDisabled))
s.mux.HandleFunc("/v1/acl/update", s.wrap(aclDisabled))
s.mux.HandleFunc("/v1/acl/delete/", s.wrap(aclDisabled))
s.mux.HandleFunc("/v1/acl/info/", s.wrap(aclDisabled))
s.mux.HandleFunc("/v1/acl/clone/", s.wrap(aclDisabled))
s.mux.HandleFunc("/v1/acl/list", s.wrap(aclDisabled))
}
if enableDebug { if enableDebug {
s.mux.HandleFunc("/debug/pprof/", pprof.Index) s.mux.HandleFunc("/debug/pprof/", pprof.Index)