Skip to content

Conversation

@devonh
Copy link
Member

@devonh devonh commented May 23, 2025

Implements: MSC4163: Make ACLs apply to EDUs

Part of #18118 to declare support for Matrix v1.13

Complement PR: matrix-org/complement#783

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

@devonh devonh requested a review from a team as a code owner May 23, 2025 21:59
@@ -0,0 +1 @@
Make ACLs apply to EDUs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any tests for ACLs on /send anywhere? I can't seem to find any and don't want to waste time reinventing the wheel trying to add tests for these 2 cases.

There is tests/federation_acl_test.go in Complement

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complement PR: matrix-org/complement#783

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Complement PR is still in draft and has a piece of pending review

await self.check_server_matches_acl(origin_host, room_id)
except AuthError:
logger.warning(
"Ignoring typing EDU for room %s from banned server", room_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Ignoring typing EDU for room %s from banned server", room_id
"Ignoring typing EDU for room %s from banned server because of ACL's", room_id


if to_remove:
logger.warning(
"Ignoring receipts in EDU for rooms %s from banned server %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Ignoring receipts in EDU for rooms %s from banned server %s",
"Ignoring receipts in EDU for rooms %s from banned server %s because of ACL's",

# > forbidden by the room's ACL.
if edu.edu_type == EduTypes.RECEIPT:
origin_host, _ = parse_server_name(origin)
to_remove = set()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to_remove = set()
to_remove_room_ids = set()

for room_id in edu.content.keys():
try:
await self.check_server_matches_acl(origin_host, room_id)
except AuthError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should also have a general except Exception that logger.exception(...) like below.

Perhaps we should just nest everything under that single try

)

for room_id in to_remove:
edu.content.pop(room_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutating the edu itself it fine because we're creating it in this scope. But mutating edu.content is sketchy because that comes directly from the edu_dict being passed in.

Maybe one day we can lint for this kind thing (python/mypy#11076)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants