Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration for disabling v1 bindings #267

Merged
merged 3 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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