diff options
author | Kabir Kwatra <kabir@kwatra.me> | 2022-07-05 14:53:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 12:53:51 +0100 |
commit | 43147bd65415de2477826677a08f6655ece7f38c (patch) | |
tree | 93419ce4d439014f444dfa70564caf0565138837 /setup | |
parent | b5c55faf9886bd66a33e5555ad0bb20465bf08f7 (diff) |
feat+fix: Ignore unknown keys and verify required fields are present in appservice registration files (#2550)
* fix: ignore unknown keys in appservice configs
fixes matrix-org/dendrite#1567
* feat: verify required fields in appservice configs
Diffstat (limited to 'setup')
-rw-r--r-- | setup/config/config_appservice.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/setup/config/config_appservice.go b/setup/config/config_appservice.go index ff328771..9b89fc9a 100644 --- a/setup/config/config_appservice.go +++ b/setup/config/config_appservice.go @@ -187,7 +187,7 @@ func loadAppServices(config *AppServiceAPI, derived *Derived) error { } // Load the config data into our struct - if err = yaml.UnmarshalStrict(configData, &appservice); err != nil { + if err = yaml.Unmarshal(configData, &appservice); err != nil { return err } @@ -315,6 +315,20 @@ func checkErrors(config *AppServiceAPI, derived *Derived) (err error) { } } + // Check required fields + if appservice.ID == "" { + return ConfigErrors([]string{"Application service ID is required"}) + } + if appservice.ASToken == "" { + return ConfigErrors([]string{"Application service Token is required"}) + } + if appservice.HSToken == "" { + return ConfigErrors([]string{"Homeserver Token is required"}) + } + if appservice.SenderLocalpart == "" { + return ConfigErrors([]string{"Sender Localpart is required"}) + } + // Check if the url has trailing /'s. If so, remove them appservice.URL = strings.TrimRight(appservice.URL, "/") |