-
Notifications
You must be signed in to change notification settings - Fork 70
/
conf.go
81 lines (69 loc) · 2.29 KB
/
conf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"encoding/json"
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
func (e mainEnv) setupConfRouter(router *httprouter.Router) *httprouter.Router {
router.GET("/v1/sys/configuration", e.configurationDump)
router.GET("/v1/sys/uiconfiguration", e.uiConfigurationDump)
router.GET("/v1/sys/cookiesettings", e.cookieSettings)
return router
}
func (e mainEnv) cookieSettings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
resultJSON, scriptsJSON, _, err := e.db.getLegalBasisCookieConf()
if err != nil {
returnError(w, r, "internal error", 405, err, nil)
return
}
resultUIConfJSON, _ := json.Marshal(e.conf.UI)
finalJSON := fmt.Sprintf(`{"status":"ok","ui":%s,"rows":%s,"scripts":%s}`, resultUIConfJSON, resultJSON, scriptsJSON)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
w.Write([]byte(finalJSON))
}
func (e mainEnv) configurationDump(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if e.enforceAuth(w, r, nil) == "" {
return
}
resultJSON, _ := json.Marshal(e.conf)
finalJSON := fmt.Sprintf(`{"status":"ok","configuration":%s}`, resultJSON)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
w.Write([]byte(finalJSON))
}
// UI configuration dump API call.
func (e mainEnv) uiConfigurationDump(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if len(e.conf.Notification.MagicSyncURL) != 0 &&
len(e.conf.Notification.MagicSyncToken) != 0 {
e.conf.UI.MagicLookup = true
} else {
e.conf.UI.MagicLookup = false
}
resultJSON, _ := json.Marshal(e.conf.UI)
finalJSON := fmt.Sprintf(`{"status":"ok","ui":%s}`, resultJSON)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(200)
w.Write([]byte(finalJSON))
}
func (e mainEnv) globalUserDelete(email string) {
// not implemented
}
func (dbobj dbcon) GetTenantAdmin(cfg Config) string {
return cfg.Generic.AdminEmail
}
func (e mainEnv) pluginUserDelete(pluginid string, userTOKEN string) {
// not implemented
}
func (e mainEnv) pluginUserLookup(email string) string {
// not implemented
return ""
}
func (dbobj dbcon) GlobalUserChangeEmail(oldEmail string, newEmail string) {
// not implemented
}
func (dbobj dbcon) GetCode() []byte {
code := dbobj.hash[4:12]
return code
}