Add config option to disable registration

This commit is contained in:
Erik Johnston 2017-11-29 16:34:01 +00:00
parent cc12fc930a
commit 3bd2095cca
2 changed files with 12 additions and 0 deletions

View file

@ -219,6 +219,11 @@ func handleRegistrationFlow(
// TODO: Handle mapping registrationRequest parameters into session parameters // TODO: Handle mapping registrationRequest parameters into session parameters
// TODO: email / msisdn / recaptcha auth types. // TODO: email / msisdn / recaptcha auth types.
if cfg.Matrix.RegistrationDisabled && r.Auth.Type != authtypes.LoginTypeSharedSecret {
return util.MessageResponse(403, "Registration has been disabled")
}
switch r.Auth.Type { switch r.Auth.Type {
case authtypes.LoginTypeSharedSecret: case authtypes.LoginTypeSharedSecret:
if cfg.Matrix.RegistrationSharedSecret == "" { if cfg.Matrix.RegistrationSharedSecret == "" {
@ -299,6 +304,10 @@ func LegacyRegister(
} }
} }
if cfg.Matrix.RegistrationDisabled && r.Auth.Type != authtypes.LoginTypeSharedSecret {
return util.MessageResponse(403, "Registration has been disabled")
}
switch r.Type { switch r.Type {
case authtypes.LoginTypeSharedSecret: case authtypes.LoginTypeSharedSecret:
if cfg.Matrix.RegistrationSharedSecret == "" { if cfg.Matrix.RegistrationSharedSecret == "" {

View file

@ -83,6 +83,9 @@ type Dendrite struct {
// If set, allows registration by anyone who also has the shared // If set, allows registration by anyone who also has the shared
// secret, even if registration is otherwise disabled. // secret, even if registration is otherwise disabled.
RegistrationSharedSecret string `yaml:"registration_shared_secret"` RegistrationSharedSecret string `yaml:"registration_shared_secret"`
// If set disables new users from registering (excpet via shared
// secrets)
RegistrationDisabled bool `yaml:"registration_disabled"`
} `yaml:"matrix"` } `yaml:"matrix"`
// The configuration specific to the media repostitory. // The configuration specific to the media repostitory.