mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 23:43:55 +01:00
Include the list of bad room ids in the error
This commit is contained in:
parent
251aafccca
commit
0ee0138325
2 changed files with 24 additions and 2 deletions
|
@ -120,6 +120,22 @@ class AuthError(SynapseError):
|
||||||
super(AuthError, self).__init__(*args, **kwargs)
|
super(AuthError, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class GuestAccessError(AuthError):
|
||||||
|
"""An error raised when a there is a problem with a guest user accessing
|
||||||
|
a room"""
|
||||||
|
|
||||||
|
def __init__(self, rooms, *args, **kwargs):
|
||||||
|
self.rooms = rooms
|
||||||
|
super(GuestAccessError, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def error_dict(self):
|
||||||
|
return cs_error(
|
||||||
|
self.msg,
|
||||||
|
self.errcode,
|
||||||
|
rooms=self.rooms,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EventSizeError(SynapseError):
|
class EventSizeError(SynapseError):
|
||||||
"""An error raised when an event is too big."""
|
"""An error raised when an event is too big."""
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
|
|
||||||
from synapse.api.constants import Membership, EventTypes
|
from synapse.api.constants import Membership, EventTypes
|
||||||
from synapse.api.errors import AuthError
|
from synapse.api.errors import GuestAccessError
|
||||||
from synapse.util import unwrapFirstError
|
from synapse.util import unwrapFirstError
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
@ -139,10 +139,16 @@ class SyncHandler(BaseHandler):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if sync_config.is_guest:
|
if sync_config.is_guest:
|
||||||
|
bad_rooms = []
|
||||||
for room_id in sync_config.filter.list_rooms():
|
for room_id in sync_config.filter.list_rooms():
|
||||||
world_readable = yield self._is_world_readable(room_id)
|
world_readable = yield self._is_world_readable(room_id)
|
||||||
if not world_readable:
|
if not world_readable:
|
||||||
raise AuthError(403, "Guest access not allowed")
|
bad_rooms.append(room_id)
|
||||||
|
|
||||||
|
if bad_rooms:
|
||||||
|
raise GuestAccessError(
|
||||||
|
bad_rooms, 403, "Guest access not allowed"
|
||||||
|
)
|
||||||
|
|
||||||
if timeout == 0 or since_token is None or full_state:
|
if timeout == 0 or since_token is None or full_state:
|
||||||
# we are going to return immediately, so don't bother calling
|
# we are going to return immediately, so don't bother calling
|
||||||
|
|
Loading…
Reference in a new issue