diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go index de4501e96..cc73db963 100644 --- a/cmd/peer-rest-server.go +++ b/cmd/peer-rest-server.go @@ -172,6 +172,11 @@ func (s *peerRESTServer) DeletePolicyHandler(w http.ResponseWriter, r *http.Requ return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) policyName := vars[peerRESTPolicy] if policyName == "" { @@ -200,6 +205,11 @@ func (s *peerRESTServer) LoadPolicyHandler(w http.ResponseWriter, r *http.Reques return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) policyName := vars[peerRESTPolicy] if policyName == "" { @@ -228,6 +238,11 @@ func (s *peerRESTServer) LoadPolicyMappingHandler(w http.ResponseWriter, r *http return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) userOrGroup := vars[peerRESTUserOrGroup] if userOrGroup == "" { @@ -257,6 +272,11 @@ func (s *peerRESTServer) DeleteUserHandler(w http.ResponseWriter, r *http.Reques return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) accessKey := vars[peerRESTUser] if accessKey == "" { @@ -285,6 +305,11 @@ func (s *peerRESTServer) LoadUserHandler(w http.ResponseWriter, r *http.Request) return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) accessKey := vars[peerRESTUser] if accessKey == "" { @@ -313,6 +338,17 @@ func (s *peerRESTServer) LoadUsersHandler(w http.ResponseWriter, r *http.Request return } + objAPI := newObjectLayerWithoutSafeModeFn() + if objAPI == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + err := globalIAMSys.Load() if err != nil { s.writeErrorResponse(w, err) @@ -335,6 +371,11 @@ func (s *peerRESTServer) LoadGroupHandler(w http.ResponseWriter, r *http.Request return } + if globalIAMSys == nil { + s.writeErrorResponse(w, errServerNotInitialized) + return + } + vars := mux.Vars(r) group := vars[peerRESTGroup] err := globalIAMSys.LoadGroup(objAPI, group)