mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 15:08:28 +00:00
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
This commit is contained in:
parent
b5c55faf98
commit
43147bd654
1 changed files with 15 additions and 1 deletions
|
@ -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, "/")
|
||||
|
||||
|
|
Loading…
Reference in a new issue