summary refs log tree commit diff
path: root/synapse/event_auth.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2019-01-29 22:54:25 +0000
committerGitHub <noreply@github.com>2019-01-29 22:54:25 +0000
commit7740eddd04504af1f60a96dda08d01904a238e0b (patch)
tree4cc0284a797c9d240c10b8d4912bba1132ff289c /synapse/event_auth.py
parentMerge pull request #4483 from matrix-org/erikj/event_v2 (diff)
parentUpdate comment (diff)
downloadsynapse-7740eddd04504af1f60a96dda08d01904a238e0b.tar.xz
Merge pull request #4514 from matrix-org/erikj/remove_event_id
Remove usages of event ID's domain
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r--synapse/event_auth.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py
index 9adedbbb02..e8da5310ed 100644
--- a/synapse/event_auth.py
+++ b/synapse/event_auth.py
@@ -20,7 +20,13 @@ from signedjson.key import decode_verify_key_bytes
 from signedjson.sign import SignatureVerifyException, verify_signed_json
 from unpaddedbase64 import decode_base64
 
-from synapse.api.constants import KNOWN_ROOM_VERSIONS, EventTypes, JoinRules, Membership
+from synapse.api.constants import (
+    KNOWN_ROOM_VERSIONS,
+    EventFormatVersions,
+    EventTypes,
+    JoinRules,
+    Membership,
+)
 from synapse.api.errors import AuthError, EventSizeError, SynapseError
 from synapse.types import UserID, get_domain_from_id
 
@@ -49,7 +55,6 @@ def check(room_version, event, auth_events, do_sig_check=True, do_size_check=Tru
 
     if do_sig_check:
         sender_domain = get_domain_from_id(event.sender)
-        event_id_domain = get_domain_from_id(event.event_id)
 
         is_invite_via_3pid = (
             event.type == EventTypes.Member
@@ -66,9 +71,13 @@ def check(room_version, event, auth_events, do_sig_check=True, do_size_check=Tru
             if not is_invite_via_3pid:
                 raise AuthError(403, "Event not signed by sender's server")
 
-        # Check the event_id's domain has signed the event
-        if not event.signatures.get(event_id_domain):
-            raise AuthError(403, "Event not signed by sending server")
+        if event.format_version in (EventFormatVersions.V1,):
+            # Only older room versions have event IDs to check.
+            event_id_domain = get_domain_from_id(event.event_id)
+
+            # Check the origin domain has signed the event
+            if not event.signatures.get(event_id_domain):
+                raise AuthError(403, "Event not signed by sending server")
 
     if auth_events is None:
         # Oh, we don't know what the state of the room was, so we