summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-03 11:33:28 +0000
committerErik Johnston <erik@matrix.org>2014-11-03 11:33:28 +0000
commit7249785bcbe86a4e1c7f6b4f4f5b0601f8a8c47a (patch)
tree03e7f21bf6ba32a3ca587cc5a5f7a06b27816717
parentAdd 'origin' key to events (diff)
downloadsynapse-7249785bcbe86a4e1c7f6b4f4f5b0601f8a8c47a.tar.xz
Sign events we create.
-rw-r--r--synapse/handlers/_base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index 787a01efc5..28b64565ae 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -18,6 +18,8 @@ from synapse.api.errors import LimitExceededError
 
 from synapse.util.async import run_on_reactor
 
+from synapse.crypto.event_signing import add_hashes_and_signatures
+
 class BaseHandler(object):
 
     def __init__(self, hs):
@@ -32,6 +34,9 @@ class BaseHandler(object):
         self.clock = hs.get_clock()
         self.hs = hs
 
+        self.signing_key = hs.config.signing_key[0]
+        self.server_name = hs.hostname
+
     def ratelimit(self, user_id):
         time_now = self.clock.time()
         allowed, time_allowed = self.ratelimiter.send_message(
@@ -53,6 +58,10 @@ class BaseHandler(object):
 
         yield self.state_handler.annotate_state_groups(event)
 
+        yield add_hashes_and_signatures(
+            event, self.server_name, self.signing_key
+        )
+
         if not suppress_auth:
             yield self.auth.check(event, snapshot, raises=True)