Skip to content

Commit

Permalink
Merge pull request #267 from matrix-org/babolivier/disable-v1-registr…
Browse files Browse the repository at this point in the history
…ation

Allow configuration for disabling v1 bindings
  • Loading branch information
babolivier committed Feb 7, 2020
2 parents bf4b4e5 + c7ca58f commit 4c6378d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sydent/http/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions sydent/sydent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c6378d

Please sign in to comment.