summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/app.go7
-rw-r--r--app/config.go22
2 files changed, 26 insertions, 3 deletions
diff --git a/app/app.go b/app/app.go
index d97c6c385..3f70974cf 100644
--- a/app/app.go
+++ b/app/app.go
@@ -90,9 +90,10 @@ type App struct {
pluginCommands []*PluginCommand
pluginCommandsLock sync.RWMutex
- clientConfig map[string]string
- clientConfigHash string
- diagnosticId string
+ clientConfig map[string]string
+ clientConfigHash string
+ limitedClientConfig map[string]string
+ diagnosticId string
phase2PermissionsMigrationComplete bool
}
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
+}