summaryrefslogtreecommitdiffstats
path: root/api/admin.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-02-03 08:52:18 -0500
committerChristopher Speller <crspeller@gmail.com>2016-02-03 08:52:18 -0500
commit75f412c4be81abfd99e2aed8c24dd15db9ae1068 (patch)
tree7e1aeb0ced8e02b8d6bed5bdce841d3f5b99f45e /api/admin.go
parentd479b08c997d3216938a3e92c3634a8b5afdb841 (diff)
parentd153d661db7d4349d69824d318aa9ad571970606 (diff)
downloadchat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.gz
chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.bz2
chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.zip
Merge pull request #2049 from mattermost/plt-1856
PLT-1856 Add basic server audit tab to system console for EE
Diffstat (limited to 'api/admin.go')
-rw-r--r--api/admin.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/api/admin.go b/api/admin.go
index 0ca05287e..e8cb8b3c7 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api
@@ -21,6 +21,7 @@ func InitAdmin(r *mux.Router) {
sr := r.PathPrefix("/admin").Subrouter()
sr.Handle("/logs", ApiUserRequired(getLogs)).Methods("GET")
+ sr.Handle("/audits", ApiUserRequired(getAllAudits)).Methods("GET")
sr.Handle("/config", ApiUserRequired(getConfig)).Methods("GET")
sr.Handle("/save_config", ApiUserRequired(saveConfig)).Methods("POST")
sr.Handle("/test_email", ApiUserRequired(testEmail)).Methods("POST")
@@ -58,6 +59,32 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.ArrayToJson(lines)))
}
+func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
+
+ if !c.HasSystemAdminPermissions("getAllAudits") {
+ return
+ }
+
+ if result := <-Srv.Store.Audit().Get("", 200); result.Err != nil {
+ c.Err = result.Err
+ return
+ } else {
+ audits := result.Data.(model.Audits)
+ etag := audits.Etag()
+
+ if HandleEtag(etag, w, r) {
+ return
+ }
+
+ if len(etag) > 0 {
+ w.Header().Set(model.HEADER_ETAG_SERVER, etag)
+ }
+
+ w.Write([]byte(audits.ToJson()))
+ return
+ }
+}
+
func getClientConfig(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.MapToJson(utils.ClientCfg)))
}