aboutsummaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-12-23 14:11:11 +0100
committerGitHub <noreply@github.com>2022-12-23 14:11:11 +0100
commitf762ce1050f2add409a83b1eeb6da5940177cfa7 (patch)
treec19463642a73bbb8b367e3d11fd734f78cfeac31 /setup
parentf47515e38b0bbf734bf977daedd836bf85465272 (diff)
Add clientapi tests (#2916)
This PR - adds several tests for the clientapi, mostly around `/register` and auth fallback. - removes the now deprecated `homeserver` field from responses to `/register` and `/login` - slightly refactors auth fallback handling
Diffstat (limited to 'setup')
-rw-r--r--setup/config/config.go12
-rw-r--r--setup/config/config_clientapi.go7
2 files changed, 11 insertions, 8 deletions
diff --git a/setup/config/config.go b/setup/config/config.go
index 7e7ed1aa..6523a245 100644
--- a/setup/config/config.go
+++ b/setup/config/config.go
@@ -29,7 +29,7 @@ import (
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ed25519"
- yaml "gopkg.in/yaml.v2"
+ "gopkg.in/yaml.v2"
jaegerconfig "github.com/uber/jaeger-client-go/config"
jaegermetrics "github.com/uber/jaeger-lib/metrics"
@@ -314,11 +314,13 @@ func (config *Dendrite) Derive() error {
if config.ClientAPI.RecaptchaEnabled {
config.Derived.Registration.Params[authtypes.LoginTypeRecaptcha] = map[string]string{"public_key": config.ClientAPI.RecaptchaPublicKey}
- config.Derived.Registration.Flows = append(config.Derived.Registration.Flows,
- authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeRecaptcha}})
+ config.Derived.Registration.Flows = []authtypes.Flow{
+ {Stages: []authtypes.LoginType{authtypes.LoginTypeRecaptcha}},
+ }
} else {
- config.Derived.Registration.Flows = append(config.Derived.Registration.Flows,
- authtypes.Flow{Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}})
+ config.Derived.Registration.Flows = []authtypes.Flow{
+ {Stages: []authtypes.LoginType{authtypes.LoginTypeDummy}},
+ }
}
// Load application service configuration files
diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go
index 0a871da1..11628b1b 100644
--- a/setup/config/config_clientapi.go
+++ b/setup/config/config_clientapi.go
@@ -78,9 +78,6 @@ func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
c.TURN.Verify(configErrs)
c.RateLimiting.Verify(configErrs)
if c.RecaptchaEnabled {
- checkNotEmpty(configErrs, "client_api.recaptcha_public_key", c.RecaptchaPublicKey)
- checkNotEmpty(configErrs, "client_api.recaptcha_private_key", c.RecaptchaPrivateKey)
- checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", c.RecaptchaSiteVerifyAPI)
if c.RecaptchaSiteVerifyAPI == "" {
c.RecaptchaSiteVerifyAPI = "https://www.google.com/recaptcha/api/siteverify"
}
@@ -93,6 +90,10 @@ func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
if c.RecaptchaSitekeyClass == "" {
c.RecaptchaSitekeyClass = "g-recaptcha-response"
}
+ checkNotEmpty(configErrs, "client_api.recaptcha_public_key", c.RecaptchaPublicKey)
+ checkNotEmpty(configErrs, "client_api.recaptcha_private_key", c.RecaptchaPrivateKey)
+ checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", c.RecaptchaSiteVerifyAPI)
+ checkNotEmpty(configErrs, "client_api.recaptcha_sitekey_class", c.RecaptchaSitekeyClass)
}
// Ensure there is any spam counter measure when enabling registration
if !c.RegistrationDisabled && !c.OpenRegistrationWithoutVerificationEnabled {