diff --git a/sydent/http/httpserver.py b/sydent/http/httpserver.py index 2ce85ffe..98bb2b18 100644 --- a/sydent/http/httpserver.py +++ b/sydent/http/httpserver.py @@ -74,10 +74,12 @@ def __init__(self, sydent): identity.putChild(b'v2', v2) api.putChild(b'v1', v1) - v1.putChild(b'validate', validate) validate.putChild(b'email', email) validate.putChild(b'msisdn', msisdn) + if self.sydent.enable_v1_associations: + v1.putChild(b'validate', validate) + v1.putChild(b'lookup', lookup) v1.putChild(b'bulk_lookup', bulk_lookup) @@ -87,11 +89,13 @@ def __init__(self, sydent): pubkey.putChild(b'ephemeral', ephemeralPubkey) ephemeralPubkey.putChild(b'isvalid', self.sydent.servlets.ephemeralPubkeyIsValid) - v1.putChild(b'3pid', threepid) threepid.putChild(b'bind', bind) threepid.putChild(b'unbind', unbind) threepid.putChild(b'getValidated3pid', getValidated3pid) + if self.sydent.enable_v1_associations: + v1.putChild(b'3pid', threepid) + email.putChild(b'requestToken', emailReqCode) email.putChild(b'submitToken', emailValCode) diff --git a/sydent/sydent.py b/sydent/sydent.py index f566fef9..5893bd22 100644 --- a/sydent/sydent.py +++ b/sydent/sydent.py @@ -89,6 +89,9 @@ # The following can be added to your local config file to enable sentry support. # 'sentry_dsn': 'https://...' # The DSN has configured in the sentry instance project. + + # Whether clients and homeservers can register an association using v1 endpoints. + 'enable_v1_associations': 'true', }, 'db': { 'db.file': 'sydent.db', @@ -169,6 +172,10 @@ def __init__(self, cfg, reactor=twisted.internet.reactor): addr=self.cfg.get("general", "prometheus_addr"), ) + self.enable_v1_associations = parse_cfg_bool( + self.cfg.get("general", "enable_v1_associations") + ) + # See if a pepper already exists in the database # Note: This MUST be run before we start serving requests, otherwise lookups for # 3PID hashes may come in before we've completed generating them @@ -360,6 +367,10 @@ def get_config_file_path(): return os.environ.get('SYDENT_CONF', "sydent.conf") +def parse_cfg_bool(value): + return value.lower() == "true" + + if __name__ == '__main__': cfg = parse_config_file(get_config_file_path()) setup_logging(cfg)