Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
0d44f64c
Commit
0d44f64c
authored
1 year ago
by
Erik Johnston
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/develop' into release-v1.103
parents
9d7880c0
1f887907
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/16968.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/16968.bugfix
synapse/event_auth.py
+34
-9
34 additions, 9 deletions
synapse/event_auth.py
with
35 additions
and
9 deletions
changelog.d/16968.bugfix
0 → 100644
+
1
−
0
View file @
0d44f64c
Prevent locking up when checking auth rules that are independent of room state for batched auth events. Contributed by @ggogel.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/event_auth.py
+
34
−
9
View file @
0d44f64c
...
...
@@ -23,7 +23,20 @@
import
collections.abc
import
logging
import
typing
from
typing
import
Any
,
Dict
,
Iterable
,
List
,
Mapping
,
Optional
,
Set
,
Tuple
,
Union
from
typing
import
(
Any
,
ChainMap
,
Dict
,
Iterable
,
List
,
Mapping
,
MutableMapping
,
Optional
,
Set
,
Tuple
,
Union
,
cast
,
)
from
canonicaljson
import
encode_canonical_json
from
signedjson.key
import
decode_verify_key_bytes
...
...
@@ -175,12 +188,22 @@ async def check_state_independent_auth_rules(
return
# 2. Reject if event has auth_events that: ...
auth_events
:
ChainMap
[
str
,
EventBase
]
=
ChainMap
()
if
batched_auth_events
:
# Copy the batched auth events to avoid mutating them.
auth_events
=
dict
(
batched_auth_events
)
needed_auth_event_ids
=
set
(
event
.
auth_event_ids
())
-
batched_auth_events
.
keys
()
# batched_auth_events can become very large. To avoid repeatedly copying it, which
# would significantly impact performance, we use a ChainMap.
# batched_auth_events must be cast to MutableMapping because .new_child() requires
# this type. This casting is safe as the mapping is never mutated.
auth_events
=
auth_events
.
new_child
(
cast
(
MutableMapping
[
str
,
"
EventBase
"
],
batched_auth_events
)
)
needed_auth_event_ids
=
[
event_id
for
event_id
in
event
.
auth_event_ids
()
if
event_id
not
in
batched_auth_events
]
if
needed_auth_event_ids
:
auth_events
.
update
(
auth_events
=
auth_events
.
new_child
(
await
store
.
get_events
(
needed_auth_event_ids
,
redact_behaviour
=
EventRedactBehaviour
.
as_is
,
...
...
@@ -188,10 +211,12 @@ async def check_state_independent_auth_rules(
)
)
else
:
auth_events
=
await
store
.
get_events
(
event
.
auth_event_ids
(),
redact_behaviour
=
EventRedactBehaviour
.
as_is
,
allow_rejected
=
True
,
auth_events
=
auth_events
.
new_child
(
await
store
.
get_events
(
event
.
auth_event_ids
(),
redact_behaviour
=
EventRedactBehaviour
.
as_is
,
allow_rejected
=
True
,
)
)
room_id
=
event
.
room_id
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment