mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-01-12 08:39:29 -05:00
Check event auth on the worker
This commit is contained in:
parent
6b8604239f
commit
f381d63813
@ -569,6 +569,20 @@ class EventCreationHandler(object):
|
|||||||
extra_users (list(str)): Any extra users to notify about event
|
extra_users (list(str)): Any extra users to notify about event
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
yield self.auth.check_from_context(event, context)
|
||||||
|
except AuthError as err:
|
||||||
|
logger.warn("Denying new event %r because %s", event, err)
|
||||||
|
raise err
|
||||||
|
|
||||||
|
# Ensure that we can round trip before trying to persist in db
|
||||||
|
try:
|
||||||
|
dump = ujson.dumps(unfreeze(event.content))
|
||||||
|
ujson.loads(dump)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Failed to encode content: %r", event.content)
|
||||||
|
raise
|
||||||
|
|
||||||
yield self.action_generator.handle_push_actions_for_event(
|
yield self.action_generator.handle_push_actions_for_event(
|
||||||
event, context
|
event, context
|
||||||
)
|
)
|
||||||
@ -610,8 +624,8 @@ class EventCreationHandler(object):
|
|||||||
ratelimit=True,
|
ratelimit=True,
|
||||||
extra_users=[],
|
extra_users=[],
|
||||||
):
|
):
|
||||||
"""Called when we have fully built the event, and have already
|
"""Called when we have fully built the event, have already
|
||||||
calculated the push actions for the event.
|
calculated the push actions for the event, and checked auth.
|
||||||
|
|
||||||
This should only be run on master.
|
This should only be run on master.
|
||||||
"""
|
"""
|
||||||
@ -620,20 +634,6 @@ class EventCreationHandler(object):
|
|||||||
if ratelimit:
|
if ratelimit:
|
||||||
yield self.base_handler.ratelimit(requester)
|
yield self.base_handler.ratelimit(requester)
|
||||||
|
|
||||||
try:
|
|
||||||
yield self.auth.check_from_context(event, context)
|
|
||||||
except AuthError as err:
|
|
||||||
logger.warn("Denying new event %r because %s", event, err)
|
|
||||||
raise err
|
|
||||||
|
|
||||||
# Ensure that we can round trip before trying to persist in db
|
|
||||||
try:
|
|
||||||
dump = ujson.dumps(unfreeze(event.content))
|
|
||||||
ujson.loads(dump)
|
|
||||||
except Exception:
|
|
||||||
logger.exception("Failed to encode content: %r", event.content)
|
|
||||||
raise
|
|
||||||
|
|
||||||
yield self.base_handler.maybe_kick_guest_users(event, context)
|
yield self.base_handler.maybe_kick_guest_users(event, context)
|
||||||
|
|
||||||
if event.type == EventTypes.CanonicalAlias:
|
if event.type == EventTypes.CanonicalAlias:
|
||||||
|
Loading…
Reference in New Issue
Block a user