diff options
author | Erik Johnston <erik@matrix.org> | 2014-10-17 21:04:07 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-10-17 21:04:07 +0100 |
commit | f1ddbfaae42f6be373b52aa0cce66901bdad697a (patch) | |
tree | 04b2f39c91ec6098ffe3b380442787ac3ce2908f /synapse/federation/transport.py | |
parent | keep 'origin_server_ts' as 'ts' in the database to avoid needlessly updating ... (diff) | |
parent | Check that we have auth headers and fail nicely (diff) | |
download | synapse-f1ddbfaae42f6be373b52aa0cce66901bdad697a.tar.xz |
Merge branch 'release-v0.4.0' of github.com:matrix-org/synapse into develop
Diffstat (limited to 'synapse/federation/transport.py')
-rw-r--r-- | synapse/federation/transport.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/synapse/federation/transport.py b/synapse/federation/transport.py index 755eee8cf6..e7517cac4d 100644 --- a/synapse/federation/transport.py +++ b/synapse/federation/transport.py @@ -238,6 +238,11 @@ class TransportLayer(object): auth_headers = request.requestHeaders.getRawHeaders(b"Authorization") + if not auth_headers: + raise SynapseError( + 401, "Missing Authorization headers", Codes.UNAUTHORIZED, + ) + for auth in auth_headers: if auth.startswith("X-Matrix"): (origin, key, sig) = parse_auth_header(auth) @@ -256,10 +261,14 @@ class TransportLayer(object): def _with_authentication(self, handler): @defer.inlineCallbacks def new_handler(request, *args, **kwargs): - (origin, content) = yield self._authenticate_request(request) - response = yield handler( - origin, content, request.args, *args, **kwargs - ) + try: + (origin, content) = yield self._authenticate_request(request) + response = yield handler( + origin, content, request.args, *args, **kwargs + ) + except: + logger.exception("_authenticate_request failed") + raise defer.returnValue(response) return new_handler @@ -392,9 +401,13 @@ class TransportLayer(object): defer.returnValue((400, {"error": "Invalid transaction"})) return - code, response = yield self.received_handler.on_incoming_transaction( - transaction_data - ) + try: + code, response = yield self.received_handler.on_incoming_transaction( + transaction_data + ) + except: + logger.exception("on_incoming_transaction failed") + raise defer.returnValue((code, response)) |