Skip to content

Commit

Permalink
Remove Auth.check method (matrix-org#6217)
Browse files Browse the repository at this point in the history
This method was somewhat redundant, and confusing.
  • Loading branch information
richvdh authored Oct 18, 2019
1 parent 0a9d228 commit 93eaeec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
1 change: 1 addition & 0 deletions changelog.d/6217.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove Auth.check method.
19 changes: 1 addition & 18 deletions synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,10 @@ def check_from_context(self, room_version, event, context, do_sig_check=True):
)
auth_events = yield self.store.get_events(auth_events_ids)
auth_events = {(e.type, e.state_key): e for e in itervalues(auth_events)}
self.check(
event_auth.check(
room_version, event, auth_events=auth_events, do_sig_check=do_sig_check
)

def check(self, room_version, event, auth_events, do_sig_check=True):
""" Checks if this event is correctly authed.
Args:
room_version (str): version of the room
event: the event being checked.
auth_events (dict: event-key -> event): the existing room state.
Returns:
True if the auth checks pass.
"""
with Measure(self.clock, "auth.check"):
event_auth.check(
room_version, event, auth_events, do_sig_check=do_sig_check
)

@defer.inlineCallbacks
def check_joined_room(self, room_id, user_id, current_state=None):
"""Check if the user is currently joined in the room
Expand Down
7 changes: 4 additions & 3 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from twisted.internet import defer

from synapse import event_auth
from synapse.api.constants import EventTypes, Membership, RejectedReason
from synapse.api.errors import (
AuthError,
Expand Down Expand Up @@ -1763,7 +1764,7 @@ def _persist_auth_tree(self, origin, auth_events, state, event):
auth_for_e[(EventTypes.Create, "")] = create_event

try:
self.auth.check(room_version, e, auth_events=auth_for_e)
event_auth.check(room_version, e, auth_events=auth_for_e)
except SynapseError as err:
# we may get SynapseErrors here as well as AuthErrors. For
# instance, there are a couple of (ancient) events in some
Expand Down Expand Up @@ -1919,7 +1920,7 @@ def _check_for_soft_fail(self, event, state, backfilled):
}

try:
self.auth.check(room_version, event, auth_events=current_auth_events)
event_auth.check(room_version, event, auth_events=current_auth_events)
except AuthError as e:
logger.warn("Soft-failing %r because %s", event, e)
event.internal_metadata.soft_failed = True
Expand Down Expand Up @@ -2018,7 +2019,7 @@ def do_auth(self, origin, event, context, auth_events):
)

try:
self.auth.check(room_version, event, auth_events=auth_events)
event_auth.check(room_version, event, auth_events=auth_events)
except AuthError as e:
logger.warn("Failed auth resolution for %r because %s", event, e)
raise e
Expand Down

0 comments on commit 93eaeec

Please sign in to comment.