diff options
Diffstat (limited to 'synapse/config/captcha.py')
-rw-r--r-- | synapse/config/captcha.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/synapse/config/captcha.py b/synapse/config/captcha.py index 9e48f865cc..92c603f224 100644 --- a/synapse/config/captcha.py +++ b/synapse/config/captcha.py @@ -12,15 +12,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ._base import Config +from typing import Any + +from synapse.types import JsonDict + +from ._base import Config, ConfigError class CaptchaConfig(Config): section = "captcha" - def read_config(self, config, **kwargs): - self.recaptcha_private_key = config.get("recaptcha_private_key") - self.recaptcha_public_key = config.get("recaptcha_public_key") + def read_config(self, config: JsonDict, **kwargs: Any) -> None: + recaptcha_private_key = config.get("recaptcha_private_key") + if recaptcha_private_key is not None and not isinstance( + recaptcha_private_key, str + ): + raise ConfigError("recaptcha_private_key must be a string.") + self.recaptcha_private_key = recaptcha_private_key + + recaptcha_public_key = config.get("recaptcha_public_key") + if recaptcha_public_key is not None and not isinstance( + recaptcha_public_key, str + ): + raise ConfigError("recaptcha_public_key must be a string.") + self.recaptcha_public_key = recaptcha_public_key + self.enable_registration_captcha = config.get( "enable_registration_captcha", False ) @@ -30,7 +46,7 @@ class CaptchaConfig(Config): ) self.recaptcha_template = self.read_template("recaptcha.html") - def generate_config_section(self, **kwargs): + def generate_config_section(self, **kwargs: Any) -> str: return """\ ## Captcha ## # See docs/CAPTCHA_SETUP.md for full details of configuring this. |