mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Remove Auth.check method (#6217)
This method was somewhat redundant, and confusing.
This commit is contained in:
parent
0a9d22808c
commit
93eaeec75a
1
changelog.d/6217.misc
Normal file
1
changelog.d/6217.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Remove Auth.check method.
|
@ -84,25 +84,8 @@ class Auth(object):
|
|||||||
)
|
)
|
||||||
auth_events = yield self.store.get_events(auth_events_ids)
|
auth_events = yield self.store.get_events(auth_events_ids)
|
||||||
auth_events = {(e.type, e.state_key): e for e in itervalues(auth_events)}
|
auth_events = {(e.type, e.state_key): e for e in itervalues(auth_events)}
|
||||||
self.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(
|
event_auth.check(
|
||||||
room_version, event, auth_events, do_sig_check=do_sig_check
|
room_version, event, auth_events=auth_events, do_sig_check=do_sig_check
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -30,6 +30,7 @@ from unpaddedbase64 import decode_base64
|
|||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
from synapse import event_auth
|
||||||
from synapse.api.constants import EventTypes, Membership, RejectedReason
|
from synapse.api.constants import EventTypes, Membership, RejectedReason
|
||||||
from synapse.api.errors import (
|
from synapse.api.errors import (
|
||||||
AuthError,
|
AuthError,
|
||||||
@ -1763,7 +1764,7 @@ class FederationHandler(BaseHandler):
|
|||||||
auth_for_e[(EventTypes.Create, "")] = create_event
|
auth_for_e[(EventTypes.Create, "")] = create_event
|
||||||
|
|
||||||
try:
|
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:
|
except SynapseError as err:
|
||||||
# we may get SynapseErrors here as well as AuthErrors. For
|
# we may get SynapseErrors here as well as AuthErrors. For
|
||||||
# instance, there are a couple of (ancient) events in some
|
# instance, there are a couple of (ancient) events in some
|
||||||
@ -1919,7 +1920,7 @@ class FederationHandler(BaseHandler):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
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:
|
except AuthError as e:
|
||||||
logger.warn("Soft-failing %r because %s", event, e)
|
logger.warn("Soft-failing %r because %s", event, e)
|
||||||
event.internal_metadata.soft_failed = True
|
event.internal_metadata.soft_failed = True
|
||||||
@ -2018,7 +2019,7 @@ class FederationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
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:
|
except AuthError as e:
|
||||||
logger.warn("Failed auth resolution for %r because %s", event, e)
|
logger.warn("Failed auth resolution for %r because %s", event, e)
|
||||||
raise e
|
raise e
|
||||||
|
Loading…
Reference in New Issue
Block a user