summaryrefslogtreecommitdiffstats
path: root/app/config.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-06-18 12:39:22 -0400
committerGitHub <noreply@github.com>2018-06-18 12:39:22 -0400
commit6d8140337ef0f68f5177988f3c87bba5e4946399 (patch)
tree44dbe951f53f6de8cc9fceac2f51ca7a175a55bf /app/config.go
parentf48d31c7a4c0332bfd10b986eee50611ab987e7c (diff)
downloadchat-6d8140337ef0f68f5177988f3c87bba5e4946399.tar.gz
chat-6d8140337ef0f68f5177988f3c87bba5e4946399.tar.bz2
chat-6d8140337ef0f68f5177988f3c87bba5e4946399.zip
MM-8701 Limit the number of client config fields sent before user logs in (#8954)
* MM-8701 Limit the number of client config fields sent before user logs in * Fixed missing client config field * Reduced duplication between limited and regular client config
Diffstat (limited to 'app/config.go')
-rw-r--r--app/config.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/config.go b/app/config.go
index b4fbfe725..21571f291 100644
--- a/app/config.go
+++ b/app/config.go
@@ -91,6 +91,10 @@ func (a *App) ClientConfigHash() string {
return a.clientConfigHash
}
+func (a *App) LimitedClientConfig() map[string]string {
+ return a.limitedClientConfig
+}
+
func (a *App) EnableConfigWatch() {
if a.configWatcher == nil && !a.disableConfigWatch {
configWatcher, err := utils.NewConfigWatcher(a.ConfigFileName(), func() {
@@ -211,10 +215,14 @@ func (a *App) AsymmetricSigningKey() *ecdsa.PrivateKey {
func (a *App) regenerateClientConfig() {
a.clientConfig = utils.GenerateClientConfig(a.Config(), a.DiagnosticId(), a.License())
+ a.limitedClientConfig = utils.GenerateLimitedClientConfig(a.Config(), a.DiagnosticId(), a.License())
+
if key := a.AsymmetricSigningKey(); key != nil {
der, _ := x509.MarshalPKIXPublicKey(&key.PublicKey)
a.clientConfig["AsymmetricSigningPublicKey"] = base64.StdEncoding.EncodeToString(der)
+ a.limitedClientConfig["AsymmetricSigningPublicKey"] = base64.StdEncoding.EncodeToString(der)
}
+
clientConfigJSON, _ := json.Marshal(a.clientConfig)
a.clientConfigHash = fmt.Sprintf("%x", md5.Sum(clientConfigJSON))
}
@@ -291,3 +299,17 @@ func (a *App) ClientConfigWithComputed() map[string]string {
return respCfg
}
+
+// LimitedClientConfigWithComputed gets the configuration in a format suitable for sending to the client.
+func (a *App) LimitedClientConfigWithComputed() map[string]string {
+ respCfg := map[string]string{}
+ for k, v := range a.LimitedClientConfig() {
+ respCfg[k] = v
+ }
+
+ // These properties are not configurable, but nevertheless represent configuration expected
+ // by the client.
+ respCfg["NoAccounts"] = strconv.FormatBool(a.IsFirstUserAccount())
+
+ return respCfg
+}