mirror of
https://github.com/element-hq/synapse
synced 2024-09-10 14:15:10 +00:00
Only check event IDs domain signed event for V1 and V2
Since newer versions of events don't have the same format for event ID.
This commit is contained in:
parent
b8d75ef53e
commit
770b823445
1 changed files with 14 additions and 5 deletions
|
@ -20,7 +20,13 @@ from signedjson.key import decode_verify_key_bytes
|
||||||
from signedjson.sign import SignatureVerifyException, verify_signed_json
|
from signedjson.sign import SignatureVerifyException, verify_signed_json
|
||||||
from unpaddedbase64 import decode_base64
|
from unpaddedbase64 import decode_base64
|
||||||
|
|
||||||
from synapse.api.constants import KNOWN_ROOM_VERSIONS, EventTypes, JoinRules, Membership
|
from synapse.api.constants import (
|
||||||
|
KNOWN_ROOM_VERSIONS,
|
||||||
|
EventTypes,
|
||||||
|
JoinRules,
|
||||||
|
Membership,
|
||||||
|
RoomVersions,
|
||||||
|
)
|
||||||
from synapse.api.errors import AuthError, EventSizeError, SynapseError
|
from synapse.api.errors import AuthError, EventSizeError, SynapseError
|
||||||
from synapse.types import UserID, get_domain_from_id
|
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:
|
if do_sig_check:
|
||||||
sender_domain = get_domain_from_id(event.sender)
|
sender_domain = get_domain_from_id(event.sender)
|
||||||
event_id_domain = get_domain_from_id(event.event_id)
|
|
||||||
|
|
||||||
is_invite_via_3pid = (
|
is_invite_via_3pid = (
|
||||||
event.type == EventTypes.Member
|
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:
|
if not is_invite_via_3pid:
|
||||||
raise AuthError(403, "Event not signed by sender's server")
|
raise AuthError(403, "Event not signed by sender's server")
|
||||||
|
|
||||||
# Check the event_id's domain has signed the event
|
if event.format_version in (RoomVersions.V1, RoomVersions.V2):
|
||||||
if not event.signatures.get(event_id_domain):
|
# Only older room versions have event IDs to check.
|
||||||
raise AuthError(403, "Event not signed by sending server")
|
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:
|
if auth_events is None:
|
||||||
# Oh, we don't know what the state of the room was, so we
|
# Oh, we don't know what the state of the room was, so we
|
||||||
|
|
Loading…
Reference in a new issue