summaryrefslogtreecommitdiffstats
path: root/api4/system.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-04-09 12:16:11 -0400
committerJesús Espino <jespinog@gmail.com>2018-04-09 18:16:11 +0200
commit0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7 (patch)
tree4b46ef4dc50aed2171d3b5ec38117a148db7ae29 /api4/system.go
parent57ee6f505e1b231733dc73dc25d2fbe14bd6b7d5 (diff)
downloadchat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.tar.gz
chat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.tar.bz2
chat-0a6b96cb40d9dd5acca7e366df9cd14fa4eff6a7.zip
MM-9849 Added tracking of which settings are set through environment variables (#8586)
* MM-9849 Added tracking of which settings are set through environment variables * Removed old version of viper * Added forked version of viper * Fixed unit tests * Fixed more unit tests * Removed copy from App.GetEnvironmentConfig
Diffstat (limited to 'api4/system.go')
-rw-r--r--api4/system.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/api4/system.go b/api4/system.go
index b34f2af6b..c307a39b7 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -23,6 +23,7 @@ func (api *API) InitSystem() {
api.BaseRoutes.ApiRoot.Handle("/config", api.ApiSessionRequired(updateConfig)).Methods("PUT")
api.BaseRoutes.ApiRoot.Handle("/config/reload", api.ApiSessionRequired(configReload)).Methods("POST")
api.BaseRoutes.ApiRoot.Handle("/config/client", api.ApiHandler(getClientConfig)).Methods("GET")
+ api.BaseRoutes.ApiRoot.Handle("/config/environment", api.ApiSessionRequired(getEnvironmentConfig)).Methods("GET")
api.BaseRoutes.ApiRoot.Handle("/license", api.ApiSessionRequired(addLicense)).Methods("POST")
api.BaseRoutes.ApiRoot.Handle("/license", api.ApiSessionRequired(removeLicense)).Methods("DELETE")
@@ -251,6 +252,18 @@ func getClientConfig(c *Context, w http.ResponseWriter, r *http.Request) {
w.Write([]byte(model.MapToJson(c.App.ClientConfigWithComputed())))
}
+func getEnvironmentConfig(c *Context, w http.ResponseWriter, r *http.Request) {
+ if !c.App.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
+ return
+ }
+
+ envConfig := c.App.GetEnvironmentConfig()
+
+ w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+ w.Write([]byte(model.StringInterfaceToJson(envConfig)))
+}
+
func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
format := r.URL.Query().Get("format")